PHP
·
发表于 5年以前
·
阅读量:8327
双飞翼布局是在圣杯布局上进行改进,当left和right设置负margin,会上升并挡住center,圣杯布局是采用padding+relative定位,而双飞翼布局是采用margin解决。
具体代码如下
<!DOCTYPE html>
<html>
<head>
<title>双飞翼布局</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<div class="header">Header</div>
<div class="container">
<div class="center">
<div class="center-inner">Center</div>
</div>
<div class="left">Left</div>
<div class="right">Right</div>
</div>
<div class="footer">Footer</div>
</body>
</html>
index.css代码:
body{padding:0;margin:0}
.header,.footer{width:100%; background: #666;height:30px;clear:both;}
.left{
background: #34934D;
width:150px;
float:left;
margin-left:-100%;
}
.center{
background: #D6D6D6;
width:100%;
float:left;
}
.center-inner{
margin-left: 150px;
margin-right: 200px;
}
.right{
background: #EF4400;
width:200px;
float:left;
margin-left:-200px;
}
需要注意的是