关于margin

FF与IE的兼容性:
1:FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行。
(解决方案:float:left)
.dealer {
height:100px;
width:400px;
background-color:#ff0000;
}

.site {
height:50px;
width:200px;
margin-left:auto;
margin-right;auto;
background-color:#ffffff;
}
2: margin -top 负值 上移 ie6不正常
.dealer {
position:absolute;
top:20px;
height:100px;
width:400px;
background-color:#ff0000;
}

.site {
height:50px;
width:200px;
margin-top:-10px;
background-color:#ffffff;
}
3: margin加倍的问题
   设置为float的div在ie下设置的margin会加倍。这是一个ie6都存在的bug。
   解决方案是在这个div里面加上display:inline;

.dealer {
float:left;
height:100px;
width:400px;
background-color:#ff0000;
}

.site {
float:left;
height:50px;
width:200px;
margin:15px;
background-color:#000000;
}

Padding:
.dealer {
float:left;
height:100px;
width:300px!important;
width:400px;
background-color:#ff0000;
padding-left:100px;

}

.site {
float:left;
height:50px;
width:200px;
margin-top:12px ;
display:inline;
background-color:#000000;
}

Test.html:
<html>
<head>
<title>Dealer Site not Found</title>

<style type="text/css">

.dealer {
float:left;
height:100px;
width:300px!important;
width:400px;
background-color:#ff0000;
padding-left:100px;

}

.site {
float:left;
height:50px;
width:200px;
margin-top:12px ;
display:inline;
background-color:#000000;
}

</style>
</head>
<body>
<div class="dealer">
<div class="site">aaaaaaaaaaaaaaaaaaaaa</div>
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值