过程
- 先准备一个大盒子装内容
<div class="box"> </div>
.box { width: 1226px; height: 615px; background-color: red; margin: 0 auto; }
- 如何用emmet语法写一个左右的盒子,然后分配一下左右盒子大小。
.left+.right
.left { width: 234px; height: 615px; background-color: #6dd02b; float: left; } .right { width: 992px; height: 615px; background-color: #3565a4; float: left; }
- 接着在右边加8个div盒子放东西
div{$}*8
- 然后在把他下面第一级的div设置属性
.right>div { width: 234px; height: 300px; background-color: grey; float: right; margin-left: 14px; margin-bottom: 14px; }
- 最后往盒子里面放内容即可
完整代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>浮动布局练习3</title>
<style>
.box {
width: 1226px;
height: 615px;
background-color: red;
margin: 0 auto;
}
.left {
width: 234px;
height: 615px;
background-color: #6dd02b;
float: left;
}
.right {
width: 992px;
height: 615px;
background-color: #3565a4;
float: left;
}
.right>div {
width: 234px;
height: 300px;
background-color: grey;
float: right;
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>
没有回复内容