关于ie浏览器的css代码注释
使用条件注释有四点好处:是不支持条件注释的浏览器跳过而不解西;不需要脚本来分辨浏览器的版本;能按逻辑来划分代码;跨浏览器使用 三种注释格式: standard HTML comment
<!-- Comment content -->
downlevel-hidden
<!--[if expression]> HTML <![endif]-->
downlevel-revealed
<![if expression]> HTML <![endif]>
所谓的dowmlevel也就是低于IE5。0的版本
条件表达式的运算符:
IE |
[if IE] |
The only currently supported feature is the string "IE", corresponding to Internet Explorer.也就是只支持IE |
value |
[if IE 7] |
An integer or floating point numeral corresponding to the version of the browser. Returns a Boolean value of true if the version number matches the browser version. For more information, see Version Vectors 可以是一个整数或者是一个浮点数,用来表明版本号 |
! |
[if !IE] |
The NOT operator. This is placed immediately in front of the feature, operator, or subexpression to reverse the Boolean meaning of the expression. 取反元算符 |
lt |
[if lt IE 5.5] |
The less-than operator. Returns true if the first argument is less than the second argument. 小于运算符 |
lte |
[if lte IE 6] |
The less-than or equal operator. Returns true if the first argument is less than or equal to the second argument. 小于或等于运算符 |
gt |
[if gt IE 5] |
The greater-than operator. Returns true if the first argument is greater than the second argument. 大于运算符 |
gte |
[if gte IE 7] |
The greater-than or equal operator. Returns true if the first argument is greater than or equal to the second argument. 大于或等于运算符 |
( ) |
[if !(IE 7)] |
Subexpression operators. Used in conjunction with boolean operators to create more complex expressions. 就是括弧 |
& |
[if (gt IE 5)&(lt IE 7)] |
The AND operator. Returns true if all subexpressions evaluate to true 与运算符 |
| |
[if (IE 6)|(IE 7)] |
The OR operator. Returns true if any of the subexpressions evaluates to true. 或运算符 |
true |
[if true] |
Always evaluates to true. 布尔值 |
false |
[if false] |
Always evaluates to false. 布尔值 |
有一点要注意的就是在downlevel-revealed conditional comment中:(我就写出例子来不写那些解释了一看就明白)
<!--[if IE 7]>--> <h1>jkfjk</h1> <!--<![endif]-->
<!--[if IE 7]><!--> <h1>jkfjk</h1> <!--<![endif]-->
上面的代码你在IE浏览器中使用就会发现有区别了,IE的解决方法就是在前一个的前面加上了"<!"。
还有一个就是IE的版本号在小数点后又四位数,5.0453是正确的,5.0.4.5.3是错误的。但是随win2000发布的IE版本号是5.0002,只这一个特例。 呵呵,英语水平有限,有不对的地方还请指点,希望各位高手给这个板块加点人气。
本文来自: CSSPLAY中文官方网(http://www.cssplay.org.cn/) 详细出处参考:http://www.cssplay.org.cn/css-hack/20080227/96.html