How do I get all supported CSS properties in WebKit?

前端 未结 2 924
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 00:07

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         


        
相关标签:
2条回答
  • 2020-12-29 00:22

    I'm not sure about the Javascript access, but you may look up all supported properties (even the proprietaries) here: CSS property names.

    0 讨论(0)
  • 2020-12-29 00:34

    The answer is

    >> 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"
       ...

    Thanks to Anton Byrna for his solution.


    One problem still remains: getComputedStyle() does not return shortcuts like background and border.

    0 讨论(0)
提交回复
热议问题