How to check if css value is supported by the browser?

前端 未结 6 1477
温柔的废话
温柔的废话 2020-12-14 17:06

Im not very skilled in javascript so please be bear with me. Safari 6 and below and older android mobile browsers and maybe more do not support the css value VH. My DIV#id o

6条回答
  •  渐次进展
    2020-12-14 17:26

    We can since a while test from javascript if a css rule if available in the context with CSS.supports.

    (Since Firefox 22/ Chrome 28)

    console.log(
    CSS.supports("( transform-origin: 5% 5% )"),
    "\n",
    CSS.supports("( display: flex )"),
    "\n ",
    CSS.supports("( background-color: #12233212 )")
    )

    The CSS.supports() static methods returns a Boolean value indicating if the browser supports a given CSS feature, or not.

    https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports


    To go further, we can possibly use this property for browser detection.

提交回复
热议问题