双飞翼布局
body
<body>
<div class="header">header</div>
<div class="container">
<div class="middle">middle</div>
<div class="left">left</div>
<div class="right">rigth</div>
</div>
<div class="footer">footer</div>
</body>
float实现
点击查看代码
* {
margin: 0;
padding: 0;
}
.header,
.footer{
height: 100px;
background-color: cadetblue;
}
.footer{
clear:both;
}
.container{
padding-left: 200px;
padding-right: 200px;
min-width: 200px;
}
.container div{
position: relative;
float: left;
height: 300px;
}
.middle{
background-color: antiquewhite;
width: 100%;
}
.left{
width: 200px;
margin-left: -100%;
left: -200px;
background-color: brown;
}
.right{
width: 200px;
margin-left: -200px;
left: 200px;
background-color:cornflowerblue;
}
关键在于负margin,relative和padding的混合使用
float的第二种实现
也可以通过把middle标签放在后面,通过将left和right分别左右浮动使middle掉到中间。同样需要清除浮动。
标签:常用,圣杯,color,padding,width,background,left,css,200px From: https://www.cnblogs.com/badpear/p/16822509.html