<!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>小米产品展示模块</title>
<style>
* {
margin: 0;
padding: 0;
}
.content {
width: 1226px;
height: 614px;
/* background-color: #000; */
float: left;
margin: 100px 100px;
/* 此处的margin不重要 可以直接margin:0 auto */
}
.left {
width: 234px;
height: 614px;
background-color: #800080;
float: left;
margin: 0 auto;
}
div div {
width: 234px;
height: 300px;
background-color: #87ceeb;
margin-left: 14px;
margin-bottom: 14px;
margin-top: 0px;
float: left;
}
div:nth-child(n+5) {
margin-top: 0px;
}
div:nth-child(4n) {
margin-right: 0px;
}
</style>
</head>
<body>
<div class="content">
<div class="left"></div>
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
<div class="five"></div>
<div class="six"></div>
<div class="seven"></div>
<div class="eight"></div>
</div>
</body>
</html>
<!-- 如果父级的宽度不够 子元素会自动换行 -->
效果图
标签:展示,color,float,height,模块,div,margin,css,left From: https://blog.51cto.com/u_15928062/5985293