CSS兼容IE6,IE7,FIREFOX的一些收集
2007-08-23 20:24
495 查看
第一种,是CSS HACK的方法
height:20px; /*For Firefox*/
*height:25px; /*For IE7 & IE6*/
_height:20px; /*For IE6*/
注意顺序。
这样也属于CSS HACK,不过没有上面这样简洁。
#example { color: #333; } /* Moz */
* html #example { color: #666; } /* IE6 */
*+html #example { color: #999; } /* IE7 */
第二种是使用IE专用的条件注释
<!-- 其他浏览器 -->
<link rel="stylesheet" type="text/css" href="css.css" />
<!--[if IE 7]>
<!-- 适合于IE7 -->
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
<!--[if lte IE 6]>
<!-- 适合于IE6及一下 -->
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->
第三种css filter的办法,以下为经典从国外网站翻译过来的。
新建一个css样式如下:
#item {
width: 200px;
height: 200px;
background: red;
}
新建一个div,并使用前面定义的css的样式:
<div id="item">some text here</div>
在body表现这里加入lang属性,中文为zh:
<body lang="en">
现在对div元素再定义一个样式:
*:lang(en) #item{
background:green !important;
}
这样做是为了用!important覆盖原来的css样式,由于:lang选择器ie7.0并不支持,所以对这句话不会有任何作用,于是也达到了ie6.0下同样的效果,但是很不幸地的是,safari同样不支持此属性,所以需要加入以下css样式:
#item:empty {
background: green !important
}
:empty选择器为css3的规范,尽管safari并不支持此规范,但是还是会选择此元素,不管是否此元素存在,现在绿色会现在在除ie各版本以外的浏览器上。
对IE6和FF的兼容可以考虑以前的!important
height:20px; /*For Firefox*/
*height:25px; /*For IE7 & IE6*/
_height:20px; /*For IE6*/
注意顺序。
这样也属于CSS HACK,不过没有上面这样简洁。
#example { color: #333; } /* Moz */
* html #example { color: #666; } /* IE6 */
*+html #example { color: #999; } /* IE7 */
第二种是使用IE专用的条件注释
<!-- 其他浏览器 -->
<link rel="stylesheet" type="text/css" href="css.css" />
<!--[if IE 7]>
<!-- 适合于IE7 -->
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
<!--[if lte IE 6]>
<!-- 适合于IE6及一下 -->
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->
第三种css filter的办法,以下为经典从国外网站翻译过来的。
新建一个css样式如下:
#item {
width: 200px;
height: 200px;
background: red;
}
新建一个div,并使用前面定义的css的样式:
<div id="item">some text here</div>
在body表现这里加入lang属性,中文为zh:
<body lang="en">
现在对div元素再定义一个样式:
*:lang(en) #item{
background:green !important;
}
这样做是为了用!important覆盖原来的css样式,由于:lang选择器ie7.0并不支持,所以对这句话不会有任何作用,于是也达到了ie6.0下同样的效果,但是很不幸地的是,safari同样不支持此属性,所以需要加入以下css样式:
#item:empty {
background: green !important
}
:empty选择器为css3的规范,尽管safari并不支持此规范,但是还是会选择此元素,不管是否此元素存在,现在绿色会现在在除ie各版本以外的浏览器上。
对IE6和FF的兼容可以考虑以前的!important
相关文章推荐
- CSS兼容IE6,IE7,FIREFOX的一些收集
- CSS兼容IE6,IE7,FIREFOX的一些收集
- CSS兼容IE6,IE7,FIREFOX的一些收集
- CSS兼容IE6,IE7,FIREFOX的hack收集
- 完美兼容ie6,ie7,ie8以及firefox的css透明滤镜
- CSS兼容IE6、IE7、火狐(Firefox)技巧集合2
- Div+CSS浏览器兼容问题( FireFox IE6 IE7 IE8 IE9)
- ie6 ie7 ie8 共存以及Firefox浏览器CSS兼容写法
- div+css 兼容ie6 ie7 ie8 ie9和FireFox Chrome等浏览器方法
- 兼容IE6,IE7和firefox可以使用的一些css hack:
- JavaScript 在ie6 ie7 ie8和Firefox下bug兼容解决记录(包含部分CSS )
- IE6,IE7,IE8,IE9,FIREFOX,Chrome等浏览器兼容详解收集
- div+css 兼容ie6 ie7 ie8 ie9和FireFox Chrome等浏览器方法
- div+css 兼容ie6 ie7 ie8 ie9和FireFox Chrome等浏览器方法
- 兼容IE6,IE7,IE8,Firefox,Chrome,DIV+CSS垂直居中终于失败,最后三分钟用写了几行JS解决,经简单测试,还行。
- 【转】CSS完全兼容IE6、IE7、IE8、IE9和firefox方法
- 兼容ie6,ie7以及firefox的css透明滤镜
- 兼容IE6、IE7和Firefox的CSS下拉菜单
- IE6,IE7,FireFox,Opera,Safari兼容CSS的解决方法及CSS差别
- 如何让div+css兼容ie6 ie7 ie8 ie9和FireFox Chrome等浏览器