先了解圣杯布局
双飞翼与圣杯细微区别
- 双飞翼比圣杯多了一个内嵌的main-inner标签
- 双飞翼设置main-inner标签magin属性,内容由maigin撑开。就不用盒子相对定位
实现步骤
1. HTML结构
<div class="container clearfix">
<div class="main">
<div class="main-inner">main</div> //相比较圣杯布局对出来的内容盒子
</div>
<div class="left">left</div>
<div class="right">right</div>
</div>
2. 同圣杯布局类似先给main宽度100%
3. 三个盒子左浮动
4.left盒子margin-left:-100%; right盒子margin-left:-200px(right盒子自身的宽度)
这几步与圣杯布局基本一致
5. 给内容盒子一个
.main-inner {
margin-left:200px;
margin-right: 200px;
}
完整代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>双飞翼布局</title>
<style type="text/css">
header,footer {
height: 10vh;
width: 100%;
background-color: #ccc;
}
.clearfix:after {
display:table;
height: 0;
content:"";
clear: both;
}
.container > div {
height: 10vh;
}
.main {
width: 100%;
background-color: #DB5ACF;
}
.main-inner {
}
.left {
width: 200px;
background-color: #9FE444;
}
.right {
width: 200px;
background-color: #39A3CF;
}
</style>
</head>
<body>
<header>header</header>
<div class="container clearfix">
<div class="main">
<div class="main-inner">main</div>
</div>
<div class="left">left</div>
<div class="right">right</div>
</div>
<footer>footer</footer>
</body>
</html>
每天都努力一点点
谢谢你看完