紧急出大事了,css的margin问题?

来源:百度知道 编辑:UC知道 时间:2024/06/21 20:26:40
紧急出大事了,css的margin问题?
<html>
<head>
<title></title>
<style type="text/css">
body{
font-family:arial;font-size:12px;
}
.father{
background-color:#fffea6;
border:10px solid #111111;
padding:25px;
}
.son1{
background-color:#70baff;
border:1px dashed #111111;
margin:0px 0px 0px 3px;
padding:10px;
float:left;
}
.son2{
background-color:#ffd270;
border:1px dashed #111111;
padding:5px;
margin:0px;
}

</style>
</head>
<body>
<div class="father">
<div class="son1">float1</div>
<div class="son2">float2</div>
</div>

<div style="margin-left:38px;padding:10px;border:1px solid black;background-color:red;width:50px;">float1
</div>
</body>
</html>

我把

在有父元素的情况下,浮动(float)会使IE产生双倍的距离,这也就是为什么margin-left值明明是3px,而结果还是多了3px
解决的方法楼上也有人提过了,就是在.son1里加上display:inline;(忽略浮动)
希望对你有帮助

说的我都高迷糊了,你测试这个是想说明什么呢,还有给你提一点如果你给一个元素定义float:left,margin-left:3px后面一定要加上display:inline,这样做的目的是为了让其他浏览器显示的效果一样
你问的问题我没有办法回答,完全都不明白啥意思

注意你的代码!
<div style="margin-left:38px;padding:10px;border:1px solid black;background-color:red;width:50px;">float1
</div>

float1后面有个空格

并且</div>是回车后输入的!

我不懂