您的位置:首页 > 其它

总结Margin重叠现象

2016-05-17 18:52 387 查看
普通与普通大者取大

<!DOCTYPE html>
<html>
<head>
<title>box test</title>
<style type="text/css">
#box{
width: 200px;
height: 200px;
background: black;
margin-bottom: 50px;

}
#box1{
width: 300px;
height: 100px;
background: blue;
margin-top: 50px;

}

</style>
</head>
<body>
<div id="box"></div>
<div id="box1"></div>

</body>
</html>




float 与 float两者相加

<!DOCTYPE html>
<html>
<head>
<title>box test</title>
<style type="text/css">
#box{
width: 200px;
height: 200px;
background: black;
margin-bottom: 50px;
float: left;
}
#box1{
width: 1900px;
height: 100px;
background: blue;
margin-top: 50px;
float: left;
}

</style>
</head>
<body>
<div id="box"></div>
<div id="box1"></div>
</body>
</html>




float对普通无影响

<!DOCTYPE html>
<html>
<head>
<title>box test</title>
<style type="text/css">
#box{
width: 200px;
height: 200px;
background: black;
margin-bottom: 50px;
float: left;
}
#box1{
width: 300px;
height: 100px;
background: blue;
margin-top: 50px;
float: left;
}
#box2{
background: green;

height: 300px;
width: 1800px;

}
</style>
</head>
<body>
<div id="box"></div>
<div id="box1"></div>
<div id="box2"></div>
</body>
</html>




总结:普通对普通大者取大;

float与普通无影响;

float与float两者相加
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: