当前位置:网站首页>How to clear floating?
How to clear floating?
2022-07-05 11:57:00 【Xiongba is also】
The influence of floating is not cleared
- The internal height of parent element caused by child floating is 0
- The height of the sibling element of the parent element is 0, Other styles cannot be implemented

Code
<body>
<div class="father">
<div class="child1">child1</div>
<div class="child2">child2</div>
</div>
<div class="friend">friend</div>
</body>
.child1,.child2,.friend{
width:50px;
height:50px;
}
.child1{
float:left;
border:1px solid blue;
}
.child2{
float:left;
border:1px solid green;
}
.friend{
border:1px solid red;
}
.father{
border:1px solid black;
}
Method 1: Add... To the parent element .clearfix
Code
<body>
<div class="father clearfix">
<div class="child1">child1</div>
<div class="child2">child2</div>
</div>
<div class="friend">friend</div>
</body>
.child1,.child2,.friend{
width:50px;
height:50px;
}
.child1{
float:left;
border:1px solid blue;
}
.child2{
float:left;
border:1px solid green;
}
.friend{
border:1px solid red;
}
.father{
border:1px solid black;
}
.clearfix:after{
content: '';
display: block; /* perhaps table*/
clear: both;
}
.clearfix{
zoom: 1; /* IE compatible */
}
design sketch

Method 2: Add... To the parent element overflow:hidden
Code
<body>
<div class="father">
<div class="child1">child1</div>
<div class="child2">child2</div>
</div>
<div class="friend">friend</div>
</body>
.child1,.child2,.friend{
width:50px;
height:50px;
}
.child1{
float:left;
border:1px solid blue;
}
.child2{
float:left;
border:1px solid green;
}
.friend{
border:1px solid red;
}
.father{
border:1px solid black;
overflow:hidden
}
design sketch

边栏推荐
猜你喜欢
![[cloud native | kubernetes] actual battle of ingress case (13)](/img/1a/9404f6dcedd15827fa45f8f6f4c093.png)
[cloud native | kubernetes] actual battle of ingress case (13)

redis 集群模式原理

Splunk configuration 163 mailbox alarm

【 YOLOv3中Loss部分计算】

Check the debug port information in rancher and do idea remote JVM debug

Riddle 1

网络五连鞭

谜语1

Simply solve the problem that the node in the redis cluster cannot read data (error) moved

【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
随机推荐
iTOP-3568开发板NPU使用安装RKNN Toolkit Lite2
2022年国内云管平台厂商哪家好?为什么?
XML parsing
《看完就懂系列》15个方法教你玩转字符串
[calculation of loss in yolov3]
871. Minimum Number of Refueling Stops
Is it difficult to apply for a job after graduation? "Hundreds of days and tens of millions" online recruitment activities to solve your problems
投资理财适合女生吗?女生可以买哪些理财产品?
你做自动化测试为什么总是失败?
多表操作-子查询
【云原生 | Kubernetes篇】Ingress案例实战(十三)
leetcode:1200. Minimum absolute difference
Redirection of redis cluster
[yolov5.yaml parsing]
ACID事务理论
Network five whip
Multi table operation - sub query
Error modulenotfounderror: no module named 'cv2 aruco‘
Open3D 欧式聚类
11.(地图数据篇)OSM数据如何下载使用