have other browsers implemented conditional comments?

痴心易碎 提交于 2019-12-11 03:20:15

问题


IE allows you to do detect which version of IE is running based on their browsers comment conditions (I actually don't know if that is what they are called, someone can correct me if it is not).

<! --[if lt IE 7]> css code here.. <! [endif] -->

Does anyone know if other browsers have followed their example to determine what version of thier browser is being used?

<! --[if FF]> css code here.. <! [endif] -->
<! --[if O]> css code here.. <! [endif] -->

回答1:


In general, you shouldn't need to do this with modern browsers (FF3.6, Chrome, IE9, Safari). Also, if you target a hack at a browser that is still changing, you run the risk of the hack still working but the problem it solved being fixed, and then your fix breaks.

Hacks or conditional comments should only be aimed at old browsers (IE6 and IE7 are the main targets).




回答2:


No, conditional comments are only supported by Internet Explroer and the list of available conditions is quite astounding.

Note that you can use conditional comments to hide things from IE browsers in general:

<!--[if !IE]><!-->
<b>This HTML is not seen by IE</b>
<!--<![endif]-->

Ugly, ugly, though...




回答3:


Not that I'm aware of. Are you trying to serve up different CSS or a combo of CSS and JS/other?

Perhaps using the vendor prefixes like -moz-, -webkit- and -o- before CSS declarations might work for you in that case.




回答4:


Nope,

conditional comments are IE only.



来源:https://stackoverflow.com/questions/4821735/have-other-browsers-implemented-conditional-comments

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