首页 > 文章列表 > css overflow属性有什么用

css overflow属性有什么用

css overflow
119 2022-08-06

1、配合浮动父容器,解决父容器高度塌陷的问题。

2、利用overflow扩展盒子高度,overflow属性可以触发浏览器重新计算父元素盒子高度。

实例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
#wrap2 {
width: 55px;
border: 3px solid red;
overflow: hidden;
}
 
 
.class1 {
width: 20px;
height: 40px;
background: blue;
float: left;
}
 
 
.class2 {
width: 20px;
height: 30px;
background: yellow;
float: left;
}
 
 
.class3 {
width: 20px;
height: 30px;
background: fuchsia;
float: left;
}
 
 
.class4 {
width: 20px;
height: 20px;
background: chartreuse;
float: left;
}
</style>
<title></title>
</head>
<body>
<div id="wrap2">
<div></div>
 
<div></div>
 
<div></div>
 
<div></div>
 
</div>
</body>
</html>

本文教程操作环境:windows7系统、css3版,DELL G3电脑。