识别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]-->

[6.18]IMIDC:香港/台湾服务器月付30美元起,日本/俄罗斯服务器月付49美元起

IMIDC发布了6.18大促销活动,针对香港、台湾、日本和莫斯科独立服务器提供特别优惠价格最低月付30美元起。IMIDC名为彩虹数据(Rainbow Cloud),是一家香港本土运营商,全线产品自营,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非等地机房,CN2网络直连到中国大陆。香港服务器   $39/...

DogYun香港BGP月付14.4元主机简单测试

前些天赵容分享过DogYun(狗云)香港BGP线路AMD 5950X经典低价云服务器的信息(点击查看),刚好账户还有点余额够开个最低配,所以手贱尝试下,这些贴上简单测试信息,方便大家参考。官方网站:www.dogyun.com主机配置我搞的是最低款优惠后14.4元/月的,配置单核,512MB内存,10GB硬盘,300GB/50Mbps月流量。基本信息DogYun的VPS主机管理集成在会员中心,包括...

Hostinger 限时外贸美国主机活动 低至月12元且赠送1个COM域名

Hostinger 商家我们可能一些新用户不是太熟悉,因为我们很多新人用户都可能较多的直接从云服务器、独立服务器起步的。而Hostinger商家已经有将近十年的历史的商家,曾经主做低价虚拟主机,也是比较有知名度的,那时候也有接触过,不过一直没有过多的使用。这不这么多年过去,Hostinger商家一直比较稳妥的在运营,最近看到这个商家在改版UI后且产品上也在活动策划比较多。目前Hostinger在进...

csshack为你推荐
设备ipad支持ipad支持ipad支持ipad支持ipadipad如何上网苹果ipad无线上网卡怎么设置?ipadwifiipad的wifi打不开怎么办?win10关闭445端口如何进入注册表修改关闭445端口iexplore.exe应用程序错误iexplore.exe---应用程序错误.是什么意思?iphonewifi苹果手机怎么扫二维码连wifi
外国虚拟主机 fc2新域名 广东服务器租用 主机测评 oneasiahost 便宜域名 uk2 128m内存 evssl 标准机柜尺寸 三拼域名 bgp双线 柚子舍官网 阿里校园 Updog 万网空间管理 宏讯 百度云加速 秒杀品 浙江服务器 更多