if browser CSS3

家住魔仙堡 提交于 2019-12-20 04:32:04

问题


How do we check to see if the browser browsing a webpage is CSS3 capable. I know how to check for which browser is coming in using PHP but how do we check specifically that the browser supports CSS3.

Any ideas,

Marvellous


回答1:


PHP (and I imagine any other server-side technology) has no idea about a browser's CSS capabilities. However on the client side, you can use Modernizr and handle rendering of your page based on the guides it gives you about what CSS3 properties a browser supports.




回答2:


No browser supports all of CSS 3. Many browsers support bits of CSS 3.

You can detect some CSS 3 features with Modernizr, but that uses client side scripting.




回答3:


CSS3 is not 'one' feature that you can detect. Browsers implement parts of it one after another. So, for example, IE 9 implements parts of CSS3 like box-shadow, but does not support some other things.

What you could do is make a list of browsers that support a given CSS3 feature and test the user agent. If you do this, http://caniuse.com/ may be a good help.

But I dont recommend this. The best way to check certain features will be client-side, for example with Modernizr.

Edit: If you need to provide a fallback, do it client-side too. Modernizr optionally includes a library named yepnope, with which you can easily load files if the browser doesnt support something. This could look like this:

yepnope({
  test : Modernizr.csstransitions,
   nope : ['jquery.js', 'transitions-fallback.js']
});

This code snippet would test for csstransitions and if they are not available, it would load jQuery and the transitions fallback js file.




回答4:


You can't do a blanket check because of the patchy support of CSS3 and the variances between browsers. See here: How to check a certain CSS capability in a browser using JavaScript?




回答5:


I'd recommend you to use Modernzir - http://www.modernizr.com/




回答6:


There is some web tools that can check how your browser is css3 compatible:

Selector test

Acid3

Modernizr

And there is a lot more...




回答7:


Using PHP's get_browser function you can do

$cssversion = get_browser(null, true)['cssversion'];

This will tell you the highest version the browser supports but as others have stated browser do not support every attribute within a version.



来源:https://stackoverflow.com/questions/6506349/if-browser-css3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!