BFC(Box Formatting Context)
Body 根元素
Display 为 table、flex、inline-box
overflow 不为visible
Float 不为none
Position 为absolute、fixed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.container-1{
padding-left:300px;
background:cadetblue;
overflow: hidden;
}
.container-1 .left{
float: left;
width:300px;
margin-left:-300px;
background:burlywood;
height: 200px;
}
.container-1 .right{
background:aliceblue;
}
</style>
</head>
<body>
<div class="container-1">
<div class="left">left</div>
<div class="right">right</div>
</div>
</body>
</html>
网友评论