IE6-9版本浏览器css hack的if 语句操作有必要重申一下

1、css if hack条件语法
< !--[if ie]> only ie <![endif]-->
仅所有的win系统自带ie可识别
< !--[if ie 5.0]> only ie 5.0 <![endif]-->
只有ie5.0可以识别
< !--[if gt ie 5.0]> only ie 5.0+ <![endif]-->
ie5.0包换ie5.5都可以识别
< !--[if lt ie 6]> only ie 6- <![endif]-->
仅ie6可识别
< !--[if gte ie 6]> only ie 6/+ <![endif]-->
ie6以及ie6以下的ie5.x都可识别

<!--[if lte ie 7]> only ie 7/- <![endif]-->
仅ie7可识别
< !--[if gte ie 7]> only ie 7/+ <![endif]-->
ie7以及ie7以下的ie6、ie5.x都可识别

<!--[if ie 8]> only ie 8/- <![endif]-->
仅ie8可识别

<!--[if ie 9]> only ie 9/- <![endif]-->
仅ie9可识别

注:在 if  后加 lt gte有不同效果 (参加其它参数同理)

  • <!–[if ie 8]> = ie8 仅ie8可识别
  • <!–[if lt ie 8]> = ie7或更低版本

<!–[if gte ie 8]> = 高于或者等于ie8版本

2、div+css实例
css实例一:
让ie6-ie8显示不同的内容,div css代码如下:

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>div if条件实例</title>
</head>
<body>
你正在使用:
<!--[if ie 7]>
<h2>ie7</h2>
<![endif]-->
<!--[if ie 6]>
<h2>ie6</h2>
<![endif]-->
<!--[if ie 8]>
<h2>ie8</h2>
<![endif]-->

<!--[if ie 9]>
<h2>ie9</h2>
<![endif]-->
<br><br>
<strong>说明</strong>:如果你的浏览器版本为多少即会显示ie多少,针对ie6-ie9实验</body>
</html>

div+css实例二:说明:以上针对不同ie显示不同网页内容div+css实例实验。

让ie6-ie8显示不同css样式效果,div css代码如下:

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>css if条件hack实例</title>
<!--[if ie 6]>
<style type="text/css">
.divcss{ color:#f00;}
</style>
<![endif]-->
<!--[if ie 7]>
<style type="text/css">
.divcss{ color:#ff0;}
</style>
<![endif]-->
<!--[if ie 8]>
<style type="text/css">
.divcss{ color:#00f;}
</style>
<![endif]-->

<!--[if ie 9]>
<style type="text/css">
.divcss{ color:#000;}
</style>
<![endif]-->
</head>
<body>
<div class="divcss">
div css实验提示:<br>
我在ie6下是红颜色,在ie7下是黄颜色,在ie8下是蓝颜色,在ie9下是黑色
</div>
</body>
</html>

说明:以上实验仅实验ie6-ie9下if hack。

时间: 2024-08-07 04:32:23

IE6-9版本浏览器css hack的if 语句操作有必要重申一下的相关文章

区分IE9/IE8/IE7/IE6及其他浏览器-CSS hack

记录一下这些浏览器的hack如下: 一.IE9以及以下版本浏览器 对于IE8及其以下版本的浏览器,就是使用本文标题所提到的”\9″ hack.如下代码: .ie8_9{ color:blue; /*所有浏览器*/ color:red\0; /*IE9/IE8版本浏览器*/ } 二.IE8以及以下版本浏览器 对于IE8及其以下版本的浏览器,就是使用本文标题所提到的”\9″ hack.如下代码: .ie6_7_8{ color:blue; /*所有浏览器*/ color:red\9; /*IE8以及

IE浏览器各版本的CSS Hack

IE浏览器各版本的CSS   Hack 如下示例: .test{ color:black;/*W3C*/ color:red\9;/* IE6-IE10 */ _color:black;/*IE6*/ +color:black;/*IE7*/ color:black\9\0;/*IE9 IE10 */ } 通过这样的css,就可以专门为IE各版本做css hack了

常见浏览器CSS hack方法总结

ie6和ie7 #tip {*background:black; /*IE7 背景变黑色*/_background:orange; /*IE6 背景变橘色*/} IE8和IE9 :root .test { color:#963\9; } /* IE9 only */ firefox@-moz-document url-prefix(){.bt_comment_ico{top:-1px;}} ie系列*html .ico_tj{background:none;filter:progid:DXIma

浏览器 CSS Hack 收集

所谓的Hack就是只有特定浏览器才能识别这段hack代码.Hack 不是什么好东西,除非没有办法,我们尽量还是不要用着玩意. 下面是各个浏览器的CSS Hack 列表. Firefox 浏览器 @-moz-document url-prefix() { .selector { property: value; } } 支持所有Gecko内核的浏览器 (包括Firefox) *>.selector { property: value; } Webkit 内核浏览器 @media screen an

浏览器css hack

(1)*:  IE6+IE7都能识别*,而标准浏览器FF+IE8是不能识别*的; (2)!important: 除IE6不能识别 !important外,  FF+IE8+IE7都能识别!important ; (3)_ : 除IE6支持_ 外,  FF+IE8+IE7都不支持_; (4)\9:所有IE浏览器都识别(IE6.IE7.IE8.IE9) 示例: (1)区别FF(IE8)与IE6 IE7 backgorund:orange; FF和IE8背景色将为橘黄色 *backgorund:red

各种浏览器css hack

你在写css时样式表加上浏览器标识符就行了,各浏览器区别如下: IE都能识别*,标准浏览器(如FF)不能识别*:IE6能识别*,但不能识别 !important:IE7能识别*,也能识别 !important:IE8能识别\0,不能识别*,+,_,*加!important;FF不能识别*,但能识别 !important:例如style=”*width:10px!important; width:20px;”这样在IE6下宽度为10px,在IE7下宽度时20px 其中还有三种写法: 1种:widt

[转载]IE6、IE7、IE8、Firefox兼容性CSS HACK代码+示例 —— 浏览器

1.区别IE和非IE浏览器CSS HACK代码  #divcss5{background:blue; /*非IE 背景藍色*/background:red \9; /*IE6.IE7.IE8背景紅色*/} 2.区别IE6,IE7,IE8,FF CSS HACK [区别符号]:「\9」.「*」.「_」[示例]:  #divcss5{background:blue; /*Firefox 背景变蓝色*/background:red \9; /*IE8 背景变红色*/*background:black;

IE6、IE7、IE8、Firefox兼容性CSS HACK代码+示例

整理关于IE6.IE7.IE8.Firefox兼容性CSS HACK问题 1.区别IE和非IE浏览器CSS HACK代码 #divcss5{background:blue; /*非IE 背景藍色*/(音乐按摩椅)background:red \9; /*IE6.IE7.IE8背景紅色*/} 2.区别IE6,IE7,IE8,FF CSS HACK [区别符号]:「\9」.「*」.「_」[示例]: #divcss5{background:blue; /*Firefox 背景变蓝色*/backgrou

兼容IE6/IE7/IE8/FireFox的css hack

.color{ background-color: #CC00FF; background-color: #FF00009; *background-color: #0066FF; _background-color: #009933; } **记住上面得样式解释为顺序是 ff.ie8.ie7.ie6 ** 显示的结果: 用火狐浏览,颜色是紫色 用 IE8 浏览,颜色是红色 用 IE7 浏览,颜色是蓝色 用 IE6 浏览,颜色是绿色 IE8 最新css hack: "" 例:"