- 浮动元素的总的宽度大于父盒子宽度时,子盒子无法一行显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 300px;
height: 300px;
background-color: #ccc;
}
.box ul {
width: 200px;
}
.box ul li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 10px;
}
</style>
</head>
<body>
<div class="box">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>
把ul的宽度盖地足够大,li即可在一行显示:
.box ul {
width: 600%;
}