地址:web前端面试题库
块级格式上下文(block format context)是页面一块独立的渲染区域,具有一套独立的渲染规则
- .father{
- background-color:red;
- /* 解决 */
- /* display:flow-root */
- /* overflow:auto */
- }
- .son1{
- background-color: blue;
- width: 100px;
- height: 200px;
- float: left;
-
- }
- .son2{
- background-color: green;
- width: 200px;
- height: 100px;
- }
-
- <body>
- <div class="father">
- <div class="son1">div>
- <div class="son2">div>
- div>
- body>

2. 外边距折叠
- <style type="text/css">
- .left{
- float: left;
- width: 200px;
- height: 100px;
- background-color: green;
- }
- .right{
- float: right;
- width: 200px;
- height: 100px;
- background-color: pink;
- }
- .center{
- overflow: hidden;
- /* 如果不写,center的width和wrapper的width一样 */
- height: 100px;
- background-color: yellow;
- }
- style>
-
- <body>
- <div class="wrapper">
- <div class="left">div>
- <div class="right">div>
- <div class="center">div>
- div>
- body>