资讯中心
News
css区分IE6 IE7 IE8 FF浏览器
发布时间:2022-09-27 00:00   您所在的位置: 网站首页 > 新闻资讯 > 经验杂谈

css区分IE6 IE7 IE8 FF浏览器,CSS hack写法,上海网站建设将自个知道的总结一下,尽量全面一点,以便对初学技术人员有所赞助。

注意下边介绍的这些hack写法仅适用于XHTML1.0。假如没有在HTML最前加上

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">

此外,这里所说的IE8,不是指IE8的兼容模式,由于IE8的兼容模式其实便是IE7

IE8执行IE7成效:(上海做网站
可以在头部<head></head>之间加上
<meta http-equiv="X-UA-Compatible" content="IE=7" />


差异IE67FF/IE8
background:blue;*background:orange;
引用
显示成效:
IE 6/7
orange
FF/IE8:blue
原理:FF/IE8不支持*开头,而IE6/7都支持。

差异IE6IE7/IE8/FF:(上海做网站
background:green;_background:blue;
引用
显示成效:
IE7/8/FF
green
IE6:blue
原理:IE6支持下划线"_"IE78firefox均不支持下划线。

差异FF/IE8IE6/7:(上海网站建设
background:orange;+background:green;-background:blue;
或者
background:orange;*background:green!important;*background:blue;
引用
显示成效:
IE6
blue
IE7
green
FF/IE8:orange
原理:IE6能识别-IE7能识别+IE8FF都不能识别+
-
IE8/FF
都不识别*IE7优先识别!importantIE6不能识别!important

关于IE8hacks
.test{
color:/*\**/#00f\9; /* IE8 only */
color:#00f\9; /*
适用于所有IE版本 */
}

可同时区分IE8IE7IE6FirefoxCSS hacks
.test{
color:#000; /* Firefox */
color:/*\**/#00f\9; /* IE8 */
*color:#f00; /* IE7 */
_color:#0f0; /* IE6 */
}

本文章由新概念互动原创,如没特殊注明,转载请注明来自:http://www.jianzhan0.com/jingyand/68244.html