diff --git a/src/Elements/Elements.hbs b/src/Elements/Elements.hbs
index dda7579..2683d5b 100644
--- a/src/Elements/Elements.hbs
+++ b/src/Elements/Elements.hbs
@@ -39,31 +39,6 @@
-{{#if computedStyle}}
-
Event Listeners
diff --git a/src/Elements/Elements.js b/src/Elements/Elements.js
index 27031c3..fe7428f 100644
--- a/src/Elements/Elements.js
+++ b/src/Elements/Elements.js
@@ -19,7 +19,10 @@ import {
startWith,
isFn,
isBool,
- safeGet
+ safeGet,
+ pxToNum,
+ isNaN,
+ isNum
} from '../lib/util';
export default class Elements extends Tool
@@ -289,6 +292,37 @@ export default class Elements extends Tool
if (needNoStyle(tagName)) return ret;
let computedStyle = cssStore.getComputedStyle();
+
+ function getBoxModelValue(type)
+ {
+ let keys = ['top', 'left', 'right', 'bottom'];
+ if (type !== 'position') keys = map(keys, key => `${type}-${key}`);
+ if (type === 'border') keys = map(keys, key => `${key}-width`);
+
+ return {
+ top: boxModelValue(computedStyle[keys[0]], type),
+ left: boxModelValue(computedStyle[keys[1]], type),
+ right: boxModelValue(computedStyle[keys[2]], type),
+ bottom: boxModelValue(computedStyle[keys[3]], type)
+ };
+ }
+
+ let boxModel = {
+ margin: getBoxModelValue('margin'),
+ border: getBoxModelValue('border'),
+ padding: getBoxModelValue('padding'),
+ content: {
+ width: boxModelValue(computedStyle['width']),
+ height: boxModelValue(computedStyle['height'])
+ }
+ };
+
+ if (computedStyle['position'] !== 'static')
+ {
+ boxModel.position = getBoxModelValue('position');
+ }
+ ret.boxModel = boxModel;
+
if (this._rmDefComputedStyle) computedStyle = rmDefComputedStyle(computedStyle);
ret.rmDefComputedStyle = this._rmDefComputedStyle;
processStyleRules(computedStyle);
@@ -577,3 +611,17 @@ function rmEvent(el, type, listener, useCapture = false)
let getWinEventProto = () => safeGet(window, 'EventTarget.prototype') || window.Node.prototype;
let wrapLink = link => `
${link}`;
+
+function boxModelValue(val, type)
+{
+ if (isNum(val)) return val;
+
+ if (!isStr(val)) return '‒';
+
+ let ret = pxToNum(val);
+ if (isNaN(ret)) return val;
+
+ if (type === 'position') return ret;
+
+ return ret === 0 ? '‒' : ret;
+}
\ No newline at end of file
diff --git a/src/Elements/Elements.scss b/src/Elements/Elements.scss
index 530d822..60bfb80 100644
--- a/src/Elements/Elements.scss
+++ b/src/Elements/Elements.scss
@@ -122,9 +122,58 @@
border: 1px solid $gray-dark;
display: inline-block;
}
+ .box-model {
+ @include overflow-auto(x);
+ background: #fff;
+ font-size: $font-size-s;
+ padding: $padding;
+ text-align: center;
+ white-space: nowrap;
+ border-bottom: 1px solid $gray-light;
+ .label {
+ position: absolute;
+ margin-left: 3px;
+ padding: 0 2px;
+ }
+ .top, .left, .right, .bottom {
+ display: inline-block;
+ }
+ .left, .right {
+ vertical-align: middle;
+ }
+ .position, .margin, .border, .padding, .content {
+ position: relative;
+ background: #fff;
+ display: inline-block;
+ text-align: center;
+ vertical-align: middle;
+ padding: 3px;
+ margin: 3px;
+ }
+ .position {
+ border: 1px grey dotted;
+ }
+ .margin {
+ border: 1px dashed;
+ background: rgba(246, 178, 107, 0.66);
+ }
+ .border {
+ border: 1px #000 solid;
+ background: rgba(255, 229, 153, 0.66);
+ }
+ .padding {
+ border: 1px grey dashed;
+ background: rgba(147, 196, 125, 0.55);
+ }
+ .content {
+ border: 1px grey solid;
+ min-width: 100px;
+ background: rgba(111, 168, 220, 0.66);
+ }
+ }
.computed-style {
background: #fff;
- font-size: 12px;
+ font-size: $font-size-s;
a {
color: $blue;
}