条件注释

867 次查看

以前一直是把支持IE的CSS跟JS都与项目中的基本代码写在一起的,现在想想这确实不是个好方法,不但调试起来很不爽,而且维护起来也很麻烦。一直忘了条件注释这么个好东西,可以把支持IE的hack code单独写在一个文件里,用条件注释的方式引入。
示例如下:

<!--[if IE]>
Internet Explorer
<![endif]-->
<!--[if IE 5]>
Internet Explorer 5
<![endif]-->
<!--[if IE 5.0]>
Internet Explorer 5.0
<![endif]-->
<!--[if IE 5.5]>
Internet Explorer 5.5
<![endif]-->
<!--[if IE 6]>
Internet Explorer 6
<![endif]-->
<!--[if IE 7]>
Internet Explorer 7
<![endif]-->
<!--[if gte IE 5]>
Internet Explorer 5 and up
<![endif]-->
<!--[if lt IE 6]>
Internet Explorer lower than 6
<![endif]-->
<!--[if lte IE 5.5]>
Internet Explorer lower or equal to 5.5
<![endif]-->
<!--[if gt IE 6]>
Internet Explorer greater than 6
<![endif]-->
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
2009年6月4日 | 归档于 技术
标签: , ,
本文目前尚无任何评论.

发表评论

XHTML: 您可以使用这些标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">