看看这个示例笔:
http://codepen.io/benpearson/pen/bHJke
是否可以在不更改 HTML 或使用绝对定位的情况下让 div 4 和 5 在 div 2 旁边向上移动?
(我不能使用包含,因为每个 div 都会根据屏幕大小向不同的方向浮动。)
.wrap {
background-color: #666;
max-width: 500px;
height: 200px;
margin: 0 auto;
}
.one {
background-color: #ddd;
height: 110px;
width: 25%;
float: left;
}
.two {
background-color: #ccc;
height: 55px;
width: 50%;
float: left;
}
.three {
background-color: #bbb;
height: 35px;
width: 50%;
float: left;
}
.four {
background-color: #aaa;
height: 20px;
width: 25%;
float: right;
}
.five {
background-color: #999;
height: 20px;
width: 25%;
float: right;
}
<div class="wrap">
<div class="one">
One
</div>
<div class="two">
Two
</div>
<div class="three">
Three
</div>
<div class="four">
Four
</div>
<div class="five">
Five
</div>
</div>