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。

转载于:https://www.cnblogs.com/webeye/p/5380707.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值