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]-->
LightNode是一家成立于2002年,总部位于香港的VPS服务商。提供基于KVM虚拟化技术.支持CentOS、Ubuntu或者Windows等操作系统。公司名:厦门靠谱云股份有限公司官方网站:https://www.lightnode.com拥有高质量香港CN2 GIA与东南亚节点(河内、曼谷、迪拜等)。最低月付7.71美金,按时付费,可随时取消。灵活满足开发建站、游戏应用、外贸电商等需求。首...
最近主机参考拿到了一台恒创科技的美国VPS云服务器测试机器,那具体恒创科技美国云服务器性能到底怎么样呢?主机参考进行了一番VPS测评,大家可以参考一下,总体来说还是非常不错的,是值得购买的。非常适用于稳定建站业务需求。恒创科技服务器怎么样?恒创科技服务器好不好?henghost怎么样?henghost值不值得购买?SonderCloud服务器好不好?恒创科技henghost值不值得购买?恒创科技是...
hostodo怎么样?快到了7月4日美国独立日,hostodo现在推出了VPS大促销活动,提供4款Hostodo美国独立日活动便宜VPS,相当于7折,低至$13/年,续费同价。Hostodo美国独立日活动结束时间不定,活动机售完即止。Hostodo商家支持加密数字货币、信用卡、PayPal、支付宝、银联等付款。Hostodo美国独立日活动VPS基于KVM虚拟,NVMe阵列,1Gbps带宽,自带一个...