当前位置:网站首页>高度塌陷和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 以使其可以包含浮动元素
边栏推荐
- Will saffron become a safe and effective natural therapy for patients with arthritis?
- Article reproduction: srcnn
- Set interface
- Interviewer: how to deal with the data loss of redis master-slave cluster switching?
- Detail the execution process of JDBC query method
- How can the top 500 enterprises improve their R & D efficiency? Let's see what industry experts say!
- Reptile
- Error: slf4j: class path contains multiple slf4j bindings
- PySide6/PyQt开发经验总结(2) - 设置快捷键
- Top 10 international NFT exchanges
猜你喜欢

MySQL extensions

初学者入门:使用WordPress搭建一个专属自己的博客

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

Error: slf4j: class path contains multiple slf4j bindings

详述HashSet的add方法

Error: the source of the existing CacheManager is: urlconfigurationsource

CVPR22 | 关系意识的图神经架构搜索

js真伪数组转换

multi-table query

Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
随机推荐
Baoli food listed on Shanghai Stock Exchange: annual revenue of 1.578 billion, market value of 5.8 billion
@Simple understanding and use of conditionalonproperty
MySQL扩展
"Game engine light in light out" 4.1 unity shader and OpenGL shader
2021-03-15
「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
聊聊feign组件的一个重要类RefectiveFeign
Gartner 权威预测未来4年网络安全的8大发展趋势
Why does the class annotated with @configuration generate cglib proxy?
Mongodb slow query and index
AMD Adrenalin 22.7.1 驱动更新:OpenGL 性能翻倍,支持微软 Win11 22H2 系统
Will saffron become a safe and effective natural therapy for patients with arthritis?
文本样式
flinksql从Oracle同步数据到Doris,一共50几个字段,Oracle表中3000多万条
如何获取Class类对象
The sparksubmit. Main () method submits external parameters and remotely submits the standalone cluster task
Eccv2022 | Ru & Google proposed to use clip for zero shot target detection!
Regular expressions remove spaces at both ends
Detail the execution process of JDBC query method
正向预查和反向预查