Hack:区分IE6/IE7/IE8/FF的一些常用的方法(1)

CSS Hack法:写在样式表文件或HTML文档中,运用浏览器的HACK来达到解析不同样式表的目的~注意书写的顺序.

.selector{
color:#ff0000; /* 所有浏览器 */
color:#ff66009; /* 所有IE浏览器 */
+color:#0044dd; /* IE7 */
_color:#000; /* IE6 */
}

看看演示:

提示:你可以先修改部分代码再运行。




IE注释法:写在HTML文档中,只适用于IE浏览器,可以让各版本的IE解析不同的HTML.
语法:

<!–[if lt IE 7]>
code here
<![endif]–>

可以做一些高级点的判断:

  • gt = selects greater than(高于)
  • lt = selects less than(低于)
  • gte = selects greater than or equal to(>=)
  • lte = selects less than or equal to(<=)
  • ! = selects everything except what directly follows the “!”(选择所有,除了!)

看看演示:

提示:你可以先修改部分代码再运行。


This entry was posted in HTML & CSS and tagged . Bookmark the permalink.

发表评论

您的电子邮箱不会被公开。 标记为 * 的区域必须填写

*

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>