目前我知道的只有这几种,以width为例
*width: 100px; /* ie 6,7,8 */ _width: 100px; /* ie 6 */
但是我看blueprint css的源代码,发现了这种写法
fieldset, #IE8#HACK {...}
这样也可以?
下划线“_”针对ie6,例如:_width:100px;
星花“*”针对ie6和ie7,例如:*width:200px;
斜线+数字零针对ie8:,例如:width:300px\0;
斜线+数字九针对ie(6、7、8):,例如:width:400px\9;
在css中注意写的顺序
如果后端是 php 的话推荐开启 browscap
http://wiki.yanyao.tk/doku.php?id=bro...
或者自己手动加 html 注释于头部
<!--[if lt IE 7 ]> <html class="ie ie6"> <![endif]--> <!--[if IE 7 ]> <html class="ie ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie ie8"> <![endif]--> <!--[if IE 9 ]> <html class="ie ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]-->
我最讨厌 IE 了,发自真心的
+color: #889964; /* IE7 */
IE8 不支持 *width: 100px; 吧
我一般会这么写
color:#0000FF\9; /* ie 6,7,8 */ *color:#FFFF00; /* ie 6,7 */ _color:#FF0000; /* ie 6 */
另外#IE8#HACK是利用的了ie8独有的一个bug, ie8无法解释#xxxx#xxx这样形式,因此这一条css会被所有非ie8浏览器解析.
参考: http://codemill.studio-connect.com/20...
<!--[if lte IE 6]><style>*{position:relative}</style><table><input></table><![endif]--> <!--[if lt IE 10]><meta http-equiv="Refresh" content="0; url=http://w3c.org"><style>*{background:none;display:none;}</style><![endif]-->