识别Css兼容性问题CSShack区分IE6IE7IE8firefox

csshack  时间:2021-04-22  阅读:()

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/IE8background:blue;*background:orange;

引用

显示效果

IE 6/7 orange

FF/IE8:blue

原理 FF/IE8不支持*开头而IE6/7都支持。

区别IE6与IE7/IE8/FFbackground:green;_background:blue;

引用

显示效果

IE7/8/FF green

IE6:blue

原理 IE6支持下划线"_" IE7、 8和firefox均不支持下划线。区别FF/IE8和IE6/7background: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]-->

王小玉网-美国洛杉矶2核4G 20元/月,香港日本CN2 2核2G/119元/季,美国300G高防/80元/月!

 活动方案:美国洛杉矶 E5 2696V2 2核4G20M带宽100G流量20元/月美国洛杉矶E5 2696V2 2核4G100M带宽1000G流量99元/季香港CN2 E5 2660V2 2核2G30M CN2500G流量119元/季日本CN2E5 2660 2核2G30M CN2 500G流量119元/季美国300G高防 真实防御E5 2696V2 2核2G30M...

hostkvm:7折优惠-香港VPS韩国VPS,8折优惠-日本软银、美国CN2 GIA、新加坡直连VPS

hostkvm本月对香港国际线路的VPS、韩国CN2+bgp线路的VPS正在做7折终身优惠,对日本软银线路、美国CN2 GIA线路、新加坡直连线路的VPS进行8折终身优惠促销。所有VPS从4G内存开始支持Windows系统,当然主流Linux发行版是绝对不会缺席的!官方网站:https://hostkvm.com香港国际线路、韩国,7折优惠码:2021summer日本、美国、新加坡,8折优惠码:2...

HostWebis:美国/法国便宜服务器,100Mbps不限流量,高配置大硬盘,$44/月起

hostwebis怎么样?hostwebis昨天在webhosting发布了几款美国高配置大硬盘机器,但报价需要联系客服。看了下该商家的其它产品,发现几款美国服务器、法国服务器还比较实惠,100Mbps不限流量,高配置大硬盘,$44/月起,有兴趣的可以关注一下。HostWebis是一家国外主机品牌,官网宣称1998年就成立了,根据目标市场的不同,以不同品牌名称提供网络托管服务。2003年,通过与W...

csshack为你推荐
圆周刊社区责任编辑:如时间选项无法打开请更改支持ipad化学品安全技术说明书traceroute网络管理工具traceroute是什么程序iphonewifi苹果wifi版和4G版是什么意思,有什么区别吗google分析google分析打不开了?google搜图google搜索的网址是什么?苹果5.1完美越狱ios5.1能不能完美越狱?altools.u32A3WMME.U32是什么文件用什么打开
linuxvps lamp安装 阿云浏览器 主机评测 burstnet 免备案cdn xen 免费网络电视 云鼎网络 日本bb瘦 怎么测试下载速度 中国电信宽带测速器 银盘服务 ebay注册 免费asp空间 中国linux iki windowsserver2008 免费的加速器 优惠服务器 更多