首页 > Web开发 > 详细

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

时间:2016-04-11 23:56:18      阅读:456      评论:0      收藏:0      [点我收藏+]

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。

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

原文:http://www.cnblogs.com/webeye/p/5380707.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!