相关疑难解决方法(0)

无法从结果getComputedStyle获取margin属性的值

a的结果getComputedStyle包含一个名为"margin"的属性,但该属性""在Mozilla Firefox或Apple Safari中始终为空字符串(); 但是,在Internet Explorer(和Google Chrome)中,margin属性包含预期值(即使在IE 6中).使用getPropertyValue("margin")返回对象的方法时返回相同的结果.

如何在Firefox和Safari中获得保证金的计算值?

var el = document.body.appendChild(document.createElement('div'));
el.style.margin = '2px';
console.log(getComputedStyle(el, null).margin === ""); // false in IE and Chrome
console.log(getComputedStyle(el, null).getPropertyValue("margin") === ""); // same
Run Code Online (Sandbox Code Playgroud)

javascript

26
推荐指数
2
解决办法
4万
查看次数

标签 统计

javascript ×1