当前位置:网站首页>Clear floating mode
Clear floating mode
2022-07-06 05:42:00 【Lei Haoming】
problem
html:
<div class="f-box">
<div class="box1"></div>
<div class="box2"></div>
</div>
css:
.f-box {
background-color: pink;
}
.box1, .box2 {
width: 200px;
height: 200px;
}
.box1 {
float: left;
background: tomato;
}
.box2 {
float: left;
background: greenyellow;
}
effect :
The parent element is not opened , So it doesn't show up .
terms of settlement
One 、 Add an empty tag
Add an empty label at the end of the element and set the style clear: both
html:
<div class="f-box">
<div class="box1"></div>
<div class="box2"></div>
<div style="clear: both"></div>
</div>
Two 、 Set the parent element to BFC
Set the parent element style overflow: hidden;
perhaps display: flex;
wait . establish BFC
.f-box {
background-color: pink;
overflow: hidden;
}
3、 ... and 、 Use pseudo elements
Set parent element after
Pseudo-element clears the float
In fact, this method is similar to the first one , Just use as element instead of empty tag
.f-box::after{
content:'';
display:block;
height:0;
clear:both;
visibility:hidden;
}
After the solution
边栏推荐
- 注释、接续、转义等符号
- After the project is released, index Html is cached
- 【华为机试真题详解】检查是否存在满足条件的数字组合
- [force buckle]43 String multiplication
- Migrate Infones to stm32
- 01. 开发博客项目之项目介绍
- 02. 开发博客项目之数据存储
- [email protected]树莓派
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
猜你喜欢
Codeless June event 2022 codeless Explorer conference will be held soon; AI enhanced codeless tool launched
Rustdesk builds its own remote desktop relay server
B站刘二大人-线性回归 Pytorch
The digital economy has broken through the waves. Is Ltd a Web3.0 website with independent rights and interests?
Vulhub vulnerability recurrence 71_ Unomi
01. Project introduction of blog development project
Redis消息队列
B站刘二大人-线性回归及梯度下降
SequoiaDB湖仓一体分布式数据库2022.6月刊
Graduation design game mall
随机推荐
【经验】win11上安装visio
Pytorch代码注意的细节,容易敲错的地方
B站刘二大人-反向传播
P2802 回家
js Array 列表 实战使用总结
Quantitative description of ANC noise reduction
Detailed summary of SQL injection
移植InfoNES到STM32
Promise summary
应用安全系列之三十七:日志注入
SQLite add index
Yygh-11-timing statistics
MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
【SQL server速成之路】——身份驗證及建立和管理用戶賬戶
First acquaintance with CDN
类和对象(一)this指针详解
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Codeforces Round #804 (Div. 2) Editorial(A-B)
LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
C Advanced - data storage (Part 1)