css 网页布局学习心得
1.左右布局
<div class="container">
<div class="left" style="background: red;height: 300px;float:left;width: 30%">左右布局-左页
</div>
<div class="right" style="background: blue;height: 300px;float: left;width: 70%">左右布局-右页
</div>
</div>
![](https://img.haomeiwen.com/i12404552/21b14980022f15f4.png)
2.左中右布局
<div class="container">
<div class="left" style="background: red;height: 300px;float:left;width: 20%">左中右布局-左页
</div>
<div class="left" style="background: green;height: 300px;float:left;width: 60%">左中右布局-中页
</div>
<div class="right" style="background: blue;height: 300px;float: left;width: 20%">左右布局-右页
</div>
</div>
![](https://img.haomeiwen.com/i12404552/2b3a30b16913cefa.png)
3.水平布局
<div class="container" style="margin-right:auto;margin-left:auto;border: 1px solid red; width: 800px;height: 200px;" >
<div class="left" style="background: red;height: 300px;float:left;width: 30%">水平居中-左页
</div>
<div class="right" style="background: blue;height: 300px;float: left;width: 70%">水平居中-右页
</div>
</div>
![](https://img.haomeiwen.com/i12404552/9257aaeb6c2eca27.png)
4.垂直布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> 垂直居中</title>
</head>
<body>
<div style="width: 800px;height: 200px;background: blue;position: absolute;top:50%;left:50%;margin-top: -100px;margin-left: -400px;
" >垂直居中</div>
</body>
</html>
![](https://img.haomeiwen.com/i12404552/54b8fd423683fc73.png)
5.其他小技巧
网友评论