<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.box {
width: 1230px;
height: 615px;
margin: 100px auto;
}
.left {
width: 235px;
float: left;
height: 100%;
background-color: green;
}
.right {
float: right;
width: 980px;
height: 100%;
background-color: #1AE6E6;
}
.phone-list li{
float: left;
width: 234px;
height: 300px;
margin-right: 14px;
margin-bottom: 14px;
background-color: pink;
}
.phone-list .four {
margin-right: 0px;
}
</style>
</head>
<body>
<div class="box">
<div class="left"></div>
<div class="right">
<ul class="phone-list">
<li>123</li>
<li>123</li>
<li>123</li>
<li class="four">123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<li class="four">123</li>
</ul>
</div>
</div>
</body>
</html>
老师的做法:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>浮动布局练习3</title>
<style>
.box {
width: 1226px;
height: 615px;
background-color: pink;
margin: 0 auto;
}
.left {
float: left;
width: 234px;
height: 615px;
background-color: purple;
}
.right {
float: left;
width: 992px;
height: 615px;
background-color: skyblue;
}
.right>div {
float: left;
width: 234px;
height: 300px;
background-color: pink;
margin-left: 14px;
margin-bottom: 14px;
}
</style>
</head>
<body>
<div class="box">
<div class="left">左青龙</div>
<div class="right">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
</div>
</body>
</html>