selector{property:value; /*所有浏览器*/property:value\9; /*所有IE浏览器*/
+property:value; /* IE7 */
_property
当然注意顺序。根据CSS的优先性上面的写法分别针对Firefox、 IE8、 IE7和IE6显示值。让我们看看这个
CSS代码如下p. ie{height:60px;text-align:center; line-height:60px;border: 1px dashed
#bbb;background:#f7f7f7;font: 15;color:blue; //所有浏览器color:brown\9; //所有IE浏览器
+color:red; // IE7
_color:green; // IE6
}
HTML代碼
<body style="width:500px;margin:0 auto;">
<p class="ie">
<span style="display:block;display:none\9;">嘿嘿小子竟然也用Firefox蓝色文字。
</span>
<!--[if IE 8]>不错不错挺先进的嘛使用IE8呢文字是褐色的。 <! [endif]--><!--[if IE 7]>你 IE7红色文字 <! [endif]-->
<!--[if IE 6]>孩子虽然显示的是绿色文字不过 IE6可不是好东西呢 <! [endif]--></p>
</body>
注意下面介绍的这些hack写法仅适用于XHTML1.0。如果没有在HTML最前加上
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml">
那么效果将不一样此外这里所说的IE8不是指IE8的兼容模式因为IE8的兼容模式其实就是IE7。
区别IE6、 7与FF/IE8background:blue;*background:orange;
引用
显示效果
IE 6/7 orange
FF/IE8:blue
原理 FF/IE8不支持*开头而IE6/7都支持。
区别IE6与IE7/IE8/FFbackground:green;_background:blue;
引用
显示效果
IE7/8/FF green
IE6:blue
原理 IE6支持下划线"_" IE7、 8和firefox均不支持下划线。区别FF/IE8和IE6/7background:orange;+background:green;-background:blue;
或者background:orange;*background:green! important;*background:blue;引用
显示效果
IE6 blue
IE7 green
FF/IE8:orange
原理 IE6能识别- IE7能识别+ IE8和FF都不能识别+和-
IE8/FF都不识别* IE7优先识别! important IE6不能识别! important。关于IE8的hacks
. test{color:/*\**/#00f\9; /* IE8 only */color:#00f\9; /*适用于所有IE版本*/
}
可同时区分IE8、 IE7、 IE6、 Firefox的CSS hacks
. test{color:#000; /* Firefox */color:/*\**/#00f\9; /* IE8 */
*color:#f00; /* IE7 */
_color:#0f0; /* IE6 */
}
添加相应的注释解决兼容性问题
注释相应的Css文件
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" /><!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="css/IE6style.css" media="screen" /><! [endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="css/IE7style.css" media="screen" /><! [endif]-->
<!--[if gte IE 8]>
<link rel="stylesheet" type="text/css" href="css/IE8style.css" media="screen" />
<! [endif]-->
注释相应的Css 内容
<!--[if ie 6]>
<style>
<!--
#warp{ padding-bottom: 11px; }-->
</style>
<! [endif]-->
<!--[if ie 7]>
<style>
<!--
#warp{ padding-bottom: 11px; }
-->
</style>
<! [endif]-->
<!--[if ie 8]>
<style>
<!--
#warp{ padding-bottom: 11px; }-->
</style>
<! [endif]-->
CheapWindowsVPS是一家成立于2007年的老牌国外主机商,顾名思义,一个提供便宜的Windows系统VPS主机(同样也支持安装Linux系列的哈)的商家,可选数据中心包括美国洛杉矶、达拉斯、芝加哥、纽约、英国伦敦、法国、新加坡等等,目前商家针对VPS主机推出5折优惠码,优惠后最低4GB内存套餐月付仅4.5美元。下面列出几款VPS主机配置信息。CPU:2cores内存:4GB硬盘:60G...
iON Cloud怎么样?iON Cloud今天发布了7月份优惠,使用优惠码:VC4VF8RHFL,新购指定型号VPS半年付或以上可享八五折!iON的云服务器包括美国洛杉矶、美国圣何塞(包含了优化线路、CN2 GIA线路)、新加坡(CN2 GIA线路、PCCW线路、移动CMI线路)这几个机房或者线路可供选择,有Linux和Windows系统之分,整体来说针对中国的优化是非常明显的,机器稳定可靠,比...
Krypt这两天发布了ION平台9月份优惠信息,提供一款特选套餐年付120美元(原价$162/年),开设在洛杉矶或者圣何塞机房,支持Windows或者Linux操作系统。ion.kryptcloud.com是Krypt机房上线的云主机平台,主要提供基于KVM架构云主机产品,相对于KT主站云服务器要便宜很多,产品可选洛杉矶、圣何塞或者新加坡等地机房。洛杉矶机房CPU:2 cores内存:2GB硬盘:...