在做一个项目联系的时候,需要将4个子盒子放到一个大盒子里面,指定完高度和宽度,并且已经去除了第四个子盒子的外边距,结果还是无法移动到父盒子中
因为超过 960px 了呗 230x4+ 14*4 =976 px
其实这种建议可以用flex 布局 或者百分比 布局
<!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>
* {
margin: 0;
padding: 0;
}
.bottom {
width: 100%;
height: 270px;
display: flex;
background: blue;
justify-content: space-around;
}
.bottom div {
width: 24%;
background: red;
}
</style>
</head>
<body>
<div class="bottom">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
<script>
</script>
</html>
230 * 4 + 14 * 3 > 960,所以放不进去