如何在WebKit中获取所有支持的CSS属性? [英] How do I get all supported CSS properties in WebKit?
本文介绍了如何在WebKit中获取所有支持的CSS属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Firefox,Opera和IE中,我可以通过以下方式获取它们:
In Firefox, Opera and IE I can get them via:
>> for (k in document.body.style) console.log(k)
-> opacity
background
height
textAlign
.
... long list ...
.
pointerEvents
在WebKit中,结果大不相同:
In WebKit the result is quite different:
>> for (k in document.body.style) console.log(k)
-> cssText
length
parentRule
getPropertyValue
getPropertyCSSValue
removeProperty
getPropertyPriority
setProperty
item
getPropertyShorthand
isPropertyImplicit
更新:最新 WebKit在CSS属性中枚举
Update: latest WebKit does enumerate over CSS properties in HTMLElement.style same way all the over browsers do.
推荐答案
答案是
>> document.defaultView.getComputedStyle(document.body, '')
-> CSSStyleDeclaration
0: "background-attachment"
1: "background-clip"
2: "background-color"
3: "background-image"
4: "background-origin"
5: "background-position"
6: "background-repeat"
7: "background-size"
8: "border-bottom-color"
9: "border-bottom-left-radius"
...
感谢Anton Byrna为他的解决方案。
Thanks to Anton Byrna for his solution.
一个问题仍然存在: getComputedStyle ()
不返回如 background
和 border
的快捷方式。
One problem still remains: getComputedStyle()
does not return shortcuts like background
and border
.
这篇关于如何在WebKit中获取所有支持的CSS属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文