senyandy's blog

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

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 */

评论