当前位置:网站首页>高度塌陷和BFC
高度塌陷和BFC
2022-07-27 12:48:00 【不好意思,此人不存在】
高度塌陷和BFC
<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style> .outer{
border: 10px red solid; overflow: hidden; } .inner{
width: 100px; height: 100px; background-color: #bbffaa; /* 高度塌陷的问题: 在浮动布局中,父元素的高度默认是被子元素撑开的 当子元素浮动后,其会完全脱离文档流,子元素从文档流中脱离 将会无法撑起父元素的高度,导致父元素的高度丢失 父元素高度丢失以后,其下的元素会自动上移,导致页面的布局混乱 所以高度塌陷是浮动布局中比较常见的一个问题,这个问题我们必须要进行处理 */ float: left; } </style>
</head>
<body>
<div class="outer">
<div class="inner"></div>
</div>
</body>
</html>
BFC(Block Formatting Context)块级格式化环境
-BFC是一个css中的一个隐含的属性,可以为一个元素开启BFC
开启BFC钙元素会变成一个独立的布局区域
-元素开启BFC后的特点:
1、开启BFC的元素不会被浮动元素所覆盖
2、开启BFC的元素子元素和父元素外边距不会重叠
3、开启BFC的元素可以包含浮动的子元素
-可以通过一些特殊方式来开启元素的BFC:
1、设置元素的浮动(不推荐)
2、将元素设置为行内块元素(不推荐)
3、将元素的overflow设置为一个非visible的值
-常用的方式: 为元素设置overflow:hidden开启其BFC 以使其可以包含浮动元素
边栏推荐
- How can the top 500 enterprises improve their R & D efficiency? Let's see what industry experts say!
- v-show
- B站713故障后的多活容灾建设|TakinTalks大咖分享
- 字节跳动的 Flink OLAP 作业调度和查询执行优化实践
- 文本样式
- 改变线程状态的方法
- Specify the add method of HashSet
- "Game engine light in light out" 4.1 unity shader and OpenGL shader
- MySQL extensions
- POJ2446 Chessboard【二分图最大匹配】
猜你喜欢

Map interface

Set接口

JS true / false array conversion

Overview of famous inner classes and anonymous inner classes

Set interface

Article reproduction: srcnn

Detail throw and throws

Why does the class annotated with @configuration generate cglib proxy?

Interviewer: how to deal with the data loss of redis master-slave cluster switching?

js真伪数组转换
随机推荐
Lambda expression
SSM实战项目-前后分离(简单易懂)
Gartner authority predicts eight development trends of network security in the next four years
"Game engine light in light out" 4.1 unity shader and OpenGL shader
MySQL extensions
文本样式
Top 10 international NFT exchanges
Why do you need foreign keys?
Baoli food listed on Shanghai Stock Exchange: annual revenue of 1.578 billion, market value of 5.8 billion
Interviewer: how to deal with the data loss of redis master-slave cluster switching?
CEPH distributed storage performance tuning (6)
POJ2446 Chessboard【二分图最大匹配】
Error: slf4j: class path contains multiple slf4j bindings
Feign的两个调用处理器
Overview of static inner classes and non static inner classes
湖仓一体电商项目背景与架构介绍及基础环境准备
【萌新解题】斐波那契数列
详述throw与throws
Getting started for beginners: build your own blog with WordPress
From the perspective of it, the CIO of B2B industry talks about how to change from "cost center" to "growth center"?