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]-->
腾讯云双十一活动已于今天正式开启了,多重优惠享不停,首购服务器低至0.4折,比如1C2G5M轻量应用服务器仅48元/年起,2C4G8M也仅70元/年起;个人及企业用户还可以一键领取3500-7000元满减券,用于支付新购、续费、升级等各项账单;企业用户还可以以首年1年的价格注册.COM域名。活动页面:https://cloud.tencent.com/act/double11我们分享的信息仍然以秒...
UCloud优刻得近日针对全球大促活动进行了一次改版,这次改版更加优惠了,要比之前的优惠价格还要低一些,并且新增了1核心1G内存的快杰云服务器,2元/首年,47元/年,这个价格应该是目前市面上最低最便宜的云服务器产品了,有需要国内外便宜VPS云服务器的朋友可以关注一下。UCloud好不好,UCloud服务器怎么样?UCloud服务器值不值得购买UCloud是优刻得科技股份有限公司旗下拥有的云计算服...
LayerStack(成立于2017年),当前正在9折促销旗下的云服务器,LayerStack的云服务器采用第 3 代 AMD EPYC™ (霄龙) 处理器,DDR4内存和企业级 PCIe Gen 4 NVMe SSD。数据中心可选中国香港、日本、新加坡和洛杉矶!其中中国香港、日本和新加坡分为国际线路和CN2线路,如果选择CN2线路,价格每月要+3.2美元,付款支持paypal,支付宝,信用卡等!...