How to get all supported CSS properties in WebKit?

In Firefox, Opera, and IE, I can get them through:

  >> for (k in document.body.style) console.log (k)
 -> opacity
    background
    height
    textAlign
    .
    ... long list ...
    .
    pointerEvents 

In WebKit, the result is completely different:

  >> for (k in document.body.style) console.log (k)
 -> cssText
    length
    parentRule
    getPropertyValue
    getPropertyCSSValue
    removeProperty
    getPropertyPriority
    setProperty
    item
    getPropertyShorthand
    isPropertyImplicit 



Update: The latest WebKit lists CSS properties in HTMLElement.style , just like all browsers do.

+5
javascript dom css webkit
Apr 10 '10 at 21:01
source share
2 answers

Answer

  >> 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 Byrne for his decision .




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

+6
Apr 10 '10 at 22:17
source share

I'm not sure about access to Javascript, but you can find all supported properties (even patent holders) here: CSS property names .

+1
Apr 10 2018-10-10T00:
source share



All Articles