首页 > 网站制作
一言推荐::D 获取中...

DIV+CSS涉及到IE6/IE7/IE8/Firefox兼容性解决方案

网站制作/ 2018-05-16/

在网站设计的时候,应该注意css样式兼容不同浏览器问题,特别是对完全使用DIV CSS设计的网,就应该更注意IE6 IE7 FF对CSS样式的兼容,不然,你的网乱可能出去不想出现的效果!
DIV+CSS涉及到IE6/IE7/IE8/Firefox兼容性解决方案
//所有浏览器 通用
height: 100px;

//IE6 专用
_height: 100px;

//IE6 专用
*height: 100px;

//IE7 专用
*+height: 100px;

//IE7、FF 共用
height: 100px !important;

一、CSS HACK

1, !important

随着IE7对!important的支持, !important 方法现在只针对IE6的HACK.(注意写法.记得该声明位置需要提前.)

//以下为引用的内容:
#wrapper
{
width: 100px!important; /* IE7+FF */
width: 80px; /* IE6 */
}
2, IE6/IE7对FireFox

以下为引用的内容:
*+html 与 *html 是IE特有的标签, firefox 暂不支持.而*+html 又为 IE7特有标签. o l e o u.com

#wrapper
{
#wrapper { width: 120px; } /* FireFox */
*html #wrapper { width: 80px;} /* ie6 fixed */
*+html #wrapper { width: 60px;} /* ie7 fixed, 注意顺序 */
}
注意:
*+html 对IE7的HACK 必须保证HTML顶部有如下声明:

二、万能 float 闭合

关于 clear float 的原理可参见 [How To Clear Floats Without Structural Markup]
将以下代码加入Global CSS 中,给需要闭合的div加上 class=”clearfix” 即可,屡试不爽.

以下为引用的内容:

/* Clear Fix */.clearfix:after
{
content:”.”;
display:block;
height:0;
clear:both;
visibility:hidden;
}
.clearfix
{
display:inline-block;
}
/* Hide from IE Mac */
.clearfix {display:block;}
/* End hide from IE Mac */
/* end of clearfix */

三、其他兼容技巧

1, FF下给 div 设置 padding 后会导致 width 和 height 增加, 但IE不会.(可用!important解决) 如width:115px !important;width:120px;padding:5px;

内容来自oleou.com

TAGS:

打赏 点赞
邮箱
验证码
昵称