圣杯/双飞翼布局与负边距
- 0
#讨论区
00条评论
实时对话
loading...
左右定宽,中间自适应,利用负边距来改变文档流
html
css
html
css
<div class="content">
<div class="middle"></div>
<div class="left"></div>
<div class="right"></div>
</div>
.content {
overflow: hidden;
padding: 0 100px;
}
.middle {
position: relative;
width: 100%;
float: left;
height: 80px;
background: #f00;
}
.left {
position: relative;
width: 100px;
float: left;
left: -100px;
height: 80px;
margin-left: -100%;
background: #0f0;
}
.right {
position: relative;
width: 100px;
float: left;
right: -100px;
height: 80px;
margin-left: -100px;
background: #00f;
}
<div class="content">
<div class="middle">
<div class="inner-middle"></div>
</div>
<div class="left"></div>
<div class="right"></div>
</div>
.content {
overflow: hidden;
}
.middle {
width: 100%;
float: left;
}
.inner-middle{
width:100%;
height: 80px;
background: green;
}
.left {
width: 100px;
float: left;
height: 80px;
margin-left: -100%;
background: yellow;
}
.right {
width: 100px;
float: left;
height: 80px;
margin-left: -100px;
background: pink
}