BFC的通俗理解app
触发BFC的方法布局
BFC的特性学习
BFC的常见应用spa
代码示例code
*{
margin: 0;
padding: 0;
}
.wrapper{
margin-left: 100px;
margin-top: 100px;
width: 100px;
height: 100px;
background: black;
overflow: hidden;
/* display: inline-block; */
/* position: absolute; */
/* float: left; */
}
.content{
margin-left: 50px;
margin-top: 50px;
width: 50px;
height: 50px;
background: green;
}
<div class="wrapper">
<div class="content"></div>
</div>
复制代码
.wrapper{
overflow: hidden;
}
.demo1{
background: red;
margin-bottom: 100px;
}
.demo2{
background: green;
margin-top: 100px;
}
<div class="wrapper">
<div class="demo1"></div>
</div>
<div class="wrapper">
<div class="demo2"></div>
</div>
复制代码
*{
margin: 0;
padding: 0;
}
.box{
/* 2 建立BFC */
overflow: hidden;
margin-left: 50px;
height: 100%;
background: black;
}
.left{
/* 1 */
float: left;
width: 200px;
height: 200px;
border: 3px solid #000;
opacity: 0.5;
background: green;
}
.right{
/* 4 */
overflow: hidden;
width: 400px;
min-height: 100px;
border: 3px solid #000;
opacity: 0.5;
background: red;
}
.litter{
/* 3 */
float: left;
margin: 10px;
width: 50px;
height: 50px;
background: blue;
}
<div class="box">
<div class="left"></div>
<div class="right">
<div class="litter"></div>
<div class="litter"></div>
<div class="litter"></div>
</div>
</div>
复制代码