
1、配合浮动父容器,解决父容器高度塌陷的问题。
2、利用overflow扩展盒子高度,overflow属性可以触发浏览器重新计算父元素盒子高度。
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <!DOCTYPE html>
<html>
<head>
<meta charset= "utf-8" >
<style>
#wrap 2 {
width : 55px ;
border : 3px solid red ;
overflow : hidden ;
}
.class 1 {
width : 20px ;
height : 40px ;
background : blue ;
float : left ;
}
.class 2 {
width : 20px ;
height : 30px ;
background : yellow;
float : left ;
}
.class 3 {
width : 20px ;
height : 30px ;
background : fuchsia ;
float : left ;
}
.class 4 {
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>
|
以上就是css overflow属性的作用,希望对大家有所帮助。更多css学习指路:css教程
本文教程操作环境:windows7系统、css3版,DELL G3电脑。