css中使用if条件在各大浏览器(IE6\IE7\IE8)中hack方法解决教程

时间:2023-03-08 19:25:14
css中使用if条件在各大浏览器(IE6\IE7\IE8)中hack方法解决教程

一个滚动代码,其他浏览器都滚的好好的,就IE出现错误,DIV+CSS if条件hack,这里DIVCSS5为大家介绍针对各大浏览器(IE6\IE7\IE8)中使用if条件hack方法教程,DIV CSS IF使用与实例

一个滚动代码,其他浏览器都滚的好好的,就IE出现错误!气愤!随想起IE的条件语句,如果是IE用第一种滚动方式,如果是其他浏览器用另外一种方式;

复制代码

代码如下:

<!--[if IE]> 
<script type="text/javascript"> 
new Marquee("ygjy1",0,2,395,300,50,0,0) 
new Marquee("jbhc1",0,2,395,300,50,0,0) 
</script> 
<![endif]--> 

其他浏览器

复制代码

代码如下:

<!--[if !IE]> 
<script type="text/javascript"> 
new Marquee("ygjy1",0,3,395,303,20,4000,3000,101); 
new Marquee("jbhc1",1,3,395,303,20,4000,3000,101); 
</script> 
<!--<![endif]--> 

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可识别 
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条件实例WWW.DIVCSS5.COM实例</title> 
</head> 
<body> 
你正在使用: 
<!--[if IE 7]> 
<h2>IE7</h2> 
<![endif]--> 
<!--[if IE 6]> 
<h2>IE6</h2> 
<![endif]--> 
<!--[if IE 8]> 
<h2>IE8</h2> 
<![endif]-->

<strong>DIVCSS5说明</strong>:如果你的浏览器版本为多少即会显示IE多少,针对IE6-IE8实验CSS教程 
</body> 
</html> 

说明:以上针对不同IE显示不同网页内容DIV+CSS实例实验 
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实例 www.divcss5.com</title> 
<!--[if IE 6]> 
<style type="text/css"> 
.divcss5{ color:#F00;} 
</style> 
<![endif]--> 
<!--[if IE 7]> 
<style type="text/css"> 
.divcss5{ color:#FF0;} 
</style> 
<![endif]--> 
<!--[if IE 8]> 
<style type="text/css"> 
.divcss5{ color:#00F;} 
</style> 
<![endif]--> 
</head> 
<body> 
<div class="divcss5"> 
DIV CSS实验提示:

我在IE6下是红颜色,在IE7下是黄颜色,在IE8下是蓝颜色 
</div> 
</body> 
</html> 

说明:以上实验仅实验IE6-IE8下if HACK 
3、div css if条件hack小结 
如需更多的衍生需要,大家可通过DIVCSS5小小实验扩展,得到自己需要。以上CSS if条件 HACK实验希望对你有帮助,需要拷贝以上代码自己实际实践以便掌握为我所用只目的。