How can I detect if a browser supports the CSS @supports feature? Since Internet Explorer and Safari don't support it, my web app doesn't know which styles to apply in those browsers.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- Is TWebBrowser dependant on IE version?
Using pure CSS, you can sort of rely on the cascade to determine whether a browser understands
@supports
by making a@supports
rule with a universally-supported declaration, such as acolor
declaration, and overriding another such rule that is declared globally:In any browser that implements
@supports
correctly,#test
should have green text. Otherwise, it'll have red text.See my answer to this question for a detailed explanation of the pure CSS method.
If you're looking to detect it using JavaScript, you can use the Modernizr feature detection library as mentioned in the comments (be sure to include css-supports in your download config):