FF、IE7、IE6的CSS hack写法
作者:蛛蛛虎 日期:2010-01-03
1、!important
IE7和FF下都支持!important 的,可以用!important来区分FF、IE7和IE6的高度。
复制内容到剪贴板
程序代码
程序代码.content{background:#f00;height:100px !important;}/* FF+IE7 */
.content{background:#f00;height:200px;}/* IE6 */
.content{background:#f00;height:200px;}/* IE6 */
2、IE6/IE7对FireFox
*+html 与 *html 是IE特有的标签, firefox 暂不支持。
而*+html 又为 IE7特有标签,IE6暂不支持。
复制内容到剪贴板
程序代码
程序代码.content{background:#f00;height:100px;}/* FF */
*html .content{background:#f00;height:200px;}/* IE6 */
*+html .content{background:#f00;height:300px;}/* IE7 */
*html .content{background:#f00;height:200px;}/* IE6 */
*+html .content{background:#f00;height:300px;}/* IE7 */
复制内容到剪贴板
程序代码
程序代码height:50px; /*FF*/
*height:100px; /*For IE7 & IE6*/
_height:150px; /*For IE6*/
*height:100px; /*For IE7 & IE6*/
_height:150px; /*For IE6*/
可以用相同的原理来为IE6、IE7、FF设置不同的width,height,margin,padding等属性。
3、区别不同浏览器,Css hack写法:
区别IE6与FF:
background:orange; *background:blue;
区别IE6与IE7:
background:green !important; background:blue;
区别IE7与FF:
background:orange; *background:green;
区别FF,IE7,IE6:
background:orange; *background:green !important; *background:blue;
还有就是使用时的排序问题,我认为:不管是什么方法,书写的顺序都是firefox的写在前面,IE7的写在中间,IE6的写在最后面。
附:CSS的各种浏览器兼容一栏表:
[本日志由 蛛蛛虎 于 2010-01-03 11:58 PM 编辑]
上一篇: 加速IE8打开速度
下一篇: U盘安装Windows7
文章来自: 本站原创
Tags: css
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论

