使用 getComputedStyle().getPropertyValue() 获取边框值? (Mozilla、FF)
在某些浏览器(即 Firefox)中,getCompulatedStyle().getPropertyValue()
不会报告任何简写 CSS,例如 border
。是否有一种非特定代码的方式来获取这些速记 CSS 值?我考虑过制作一个速记 CSS 及其各自的速记 CSS 值的白名单。但我意识到这样做既会很痛苦,而且是不向前兼容的设计。
In some browsers (namely, Firefox) the getComputedStyle().getPropertyValue()
doesn't report anything for shorthand CSS, like border
. Is there a non-specific-code way of getting these shorthand CSS values? I've considered making a whitelist of shorthand CSS and their respective longhand CSS values. But I realize doing that would be both a big pain and a non-forward-compatible design.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想知道,你想用像
border: 1pxsolid #000
这样的字符串做什么?假设您想重现一个元素
border
以便复制它copyStyle(el2, el, "border")
:比较两个元素的给定样式集是否匹配可以完成以同样的方式。除此之外,我真的看不到字符串的使用,如果你想用它来计算任何东西,应该解析它。
I'm wondering, what do you want to do with a string like
border: 1px solid #000
?Say you want to reproduce an elems
border
in order to copy itcopyStyle(el2, el, "border")
:Comparing if two element's given set of styles matches can be done in the same manner. Other than that, I really can't see the use a string, which should be parsed if you want to compute anything with it.