目标:熟悉float布局
要求:用 float布局 完成八色拼图
图例:
思路:将整体切分成几个小块来处理,float相关参数
实现:
<!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;
}
div{
font-size: 30px;
text-align: center;
}
.head{
width: 500px;
height: 100px;
line-height: 100px;
background-color: green;
}
.head div{
width: 100px;
height: 100px;
float: left;
}
.mid{
width: 500px;
height: 350px;
background-color: pink;
}
.mid .left{
width: 300px;
height: 350px;
float: left;
}
.mid .right{
width: 200px;
height: 350px;
float: left;
}
.mid .left .six{
width: 300px;
height: 100px;
line-height: 100px;
background-color: yellow;
}
.mid .left .eight,.mid .left .nine{
width: 150px;
height: 150px;
line-height: 150px;
background-color: silver;
float: left;
}
.mid .left .nine{
color: white;
background-color: black;
}
.mid .left .eleven{
width: 300px;
height: 100px;
line-height: 100px;
background-color: red;
float: left;
}
.mid .right .seven{
width: 200px;
height: 220px;
line-height: 190px;
}
.mid .right .ten{
width: 200px;
height: 130px;
line-height: 130px;
background-color: aqua;
}
.tail{
width: 500px;
height: 100px;
line-height: 100px;
background-color: blue;
}
</style>
</head>
<body>
<div class="head">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="mid">
<div class="left">
<div class="six">6</div>
<div class="eight">8</div>
<div class="nine">9</div>
<div class="eleven">11</div>
</div>
<div class="right">
<div class="seven">7</div>
<div class="ten">10</div>
</div>
</div>
<div class="tail">12</div>
</body>
</html>