您的位置:首页 > 其它

IE6 / IE7 / Firefox 的margin问题解决办法

2008-09-03 19:34 232 查看
这两天在做一个网站的布局,因为经常用firefox,所有的内容都是在firefox下面调试的,等快完工了切回IE7一看,样式差别好多,主要是在margin,padding这几个元素的理解上。

我知道ie6 ie7 firefox 对margin的解释都不同,去网上查了一下,可以通过!important这样的手段hack。

具体的做法有以下几种:

第一种:

.div {

background:orange;/*ff*/

*background:green !important;/*ie7*/

*background:blue; /*ie6*/

}

第二种:

.div {

margin:10px;/*ff*/

*margin:15px;/*ie7*/

_margin:15px;/*ie6*/

}

第三种:

#div { color: #333; } /* ff */

* html #div { color: #666; } /* IE6 */

*+html #div { color: #999; } /* IE7 */

现在常用了第一种,很好用,写出来与大家分享。

在给一个例子:

#pages{margin:auto; width:910px; text-align:left; }

#pages{*width:915px !important;} /* IE7 */
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: