当前位置:网站首页>清除浮动与BFC
清除浮动与BFC
2022-08-02 18:53:00 【逃跑计划】
当给子元素设置 float 属性时,会出现子元素高度无法撑开父元素高度的问题,如下图所示:
解决办法有两种:
- 给父元素的前后伪类设置 clear: both;
.clearfix:before,
.clearfix:after {
content: ' ';
display: table;
clear: both;
}
2.创建 BFC
- position不为static和relative
- overflow不为visible
- display为inline-block, table-cell, table-caption, flex, inline-flex
.main {
width: 1200px;
padding: 20px;
margin: 100px auto;
overflow: auto; /* 创建 BFC */
}
边栏推荐
- JVM内存和垃圾回收-03.运行时数据区概述及线程
- What is the use of IT assets management software
- 元旦快乐(2022)
- I have 8 years of experience in the Ali test, and I was able to survive by relying on this understanding.
- 7.24 - 每日一题 - 408
- 备战无人机配送:互联网派To C、技术派To B
- 香农与信息论三大定律
- cache2go-源码阅读
- T5: Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
- LeetCode每日一题(324. Wiggle Sort II)
猜你喜欢
Functional test points for time, here is a comprehensive summary for you
86.(cesium之家)cesium叠加面接收阴影效果(gltf模型)
流量分析四—蓝牙
【动态规划专项训练】基础篇
Mppt photovoltaic maximum power point tracking control matlab simulation
我靠这套笔记自学,拿下字节50万offer....
【C语言刷题】Leetcode203——移除链表元素
Electronic Industry Inventory Management Pain Points and WMS Warehouse Management System Solutions
Golang swagger :missing required param comment parameters
JVM内存和垃圾回收-03.运行时数据区概述及线程
随机推荐
Three components of NIO foundation
有什么好用的IT资产管理软件
openlayers版本更新差别
register和volatile的区别
Monitor is easy to Mars debut: distributed operations help TOP3000 across management gap
I have 8 years of experience in the Ali test, and I was able to survive by relying on this understanding.
js Fetch返回数据res.json()报错问题
Jellyfin 打造家庭影院 & 视频硬解 (威联通 QNAP)
视频隐写一
What skills are the most practical for college students in communications?
博云入选 Gartner 中国 DevOps 代表厂商
arcgis 分子式标注
洛谷P2880 Balanced Lineup G
监控易火星版即将亮相:分布式运维帮助TOP3000大企业跨越管理鸿沟
7.21 - 每日一题 - 408
LeetCode每日一题(324. Wiggle Sort II)
阿里35+老测试员生涯回顾,自动化测试真的有这么吃香吗?
MySQL主从搭建(问题大聚集,告别部署烦恼)
请教下,1.0.0和1.0.2的底层数据库表结构有变化吗?
T5: Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer