预期效果如图所示:
首先用html定义所需的几个盒子结构
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>浮动</title>
<link rel="stylesheet" type="text/css" href="css/float.css"/>
</head>
<body>
<div class="box">
<div class="left"></div>
<ul class="right">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
</div>
</body>
</html>
用css实现盒子的样式
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.box {
width: 1226px;
height: 615px;
margin: auto;
background-color: gray;
}
.left {
float: left;
width: 234px;
height: 615px;
background-color: palegreen;
}
.right {
float: right;
width: 992px;
height: 615px;
background-color: paleturquoise;
}
.right li {
width: 234px;
height: 300px;
background-color: palegoldenrod;
float: left;
margin-left: 14px;
margin-bottom: 14px;
}