IE8 CSS hack
前端  /  管理员 发布于 7年前   253
针对IE8正式版的CSS hack目前可以找到的分为2种:
基本的写法:
1.
.test { color
/*\**/
:
blue
\
9
}
这个IE6、IE7、IE8都能识别;但是IE8不能识别“*”和“_”的css hack;所以我们可以这样写hack:(转载
1.
.header {
width
:
300px
;}
/* 所有浏览器*/
2.
.header {width
/*\**/
:
330px
\
9
;}
/* 所有浏览器IE浏览器 */
3.
.header {*
width
:
310px
;}
/* IE7和IE6能识别,IE8和FF不能识别*/
4.
.header {
_width
:
290px
;}
/* IE6能识别,IE7、IE8和FF不能识别*/
条件注释是IE特有的一种功能,能对IE系列产品进行单独的XHTML代码处理,注意,主要是针对XHTML,而非CSS。
条件注释功能非常强大,可以进行true和false判断,例如:
程序代码
<!–[if IE]>此内容只有IE可见<![endif]–>
<!–[if IE 6.0]>此内容只有IE6.0可见<![endif]–>
条件注释能被IE判断是什么版本的浏览器,并在符合条件的情况下显示其中的内容,从IE5.0到7.0都支持注释功能,而且版本号精确到小数点后4位:
程序代码
<!–[if IE 6.1000]>此内容只有IE6.1可见<![endif]–>
IE条件注释还支持感叹号非操作:
程序代码
<!–[if !IE 6.0]>此内容除了IE6.0版本之外都可见<![endif]–>
并且支持前缀,用于判断更高版本或是更低版本:
程序代码
<!–[if gt IE 5.0]>此内容只有IE5.0以上版本可见<![endif]–>
这里的gt全称为greater than表示当前条件版本以上版本,但不包含当前版本。
还有其它几个前缀:
lt 表示less than 当前条件版本以下的版本,不包含当前版本。
gte 表示greeter than or equal 当前版本以上版本,并包含当前版本。
lte 表示less than or equal 当前版本以下版本,并包含当前版本。
1.
.color
1
{
color
:
#F00
; color
/*\**/
:
#00F
/*\**/
}
/*IE6,IE7,IE8,FF,OP,SA识别*/
2.
.color
2
{
color
:
#F00
; color
/*\**/
:
#00F
/*\9**/
}
/*IE7,IE8,FF,OP,SA识别*/
3.
.color
3
{
color
:
#F00
; color
/*\**/
:
#00F
\
9
}
/*IE6,IE7,IE8识别*/
4.
.color
4
{
color
:
#F00
; color
/*\**/
:
#00F
\
9
}
/*IE7,IE8识别*/
/*“color”和“/*\**/
”之间有个空格*/
其中:OP表示Opera,SA表示Safari
参考阅读:
http://ladysign-apps.com/blog/archives/529
http://webdevelop.nitamihai.com/ie8-css-hack/
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>区别IE6、IE7、IE8、FireFox的CSS hack - www.newcss.cn</title>
<style type="text/css">
<!--
#test,#note{
margin:0 auto;
text-align:center;
}
#test {
width:200px;
height:30px;
border: 1px solid #000000;
color:#fff;
line-height:30px;
}
.color{
background-color: #CC00FF; /*所有浏览器都会显示为紫色*/
background-color: #FF0000\9; /*IE6、IE7、IE8会显示红色*/
*background-color: #0066FF; /*IE6、IE7会变为蓝色*/
_background-color: #009933; /*IE6会变为绿色*/
}
-->
</style>
</head>
<body>
<div id="test" class="color">测试方块 hi.baidu.com/dpxdqx </div>
<div id="note">
<strong style="color:#009933">IE6</strong>
<strong style="color:#0066FF">IE7</strong>
<strong style="color:#FF0000">IE8</strong>
<strong style="color:#CC00FF">FireFox</strong>
</div>
</body>
</html>
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号