【发布时间】:2016-06-26 11:19:26
【问题描述】:
我的内容布局由三个部分组成:页眉、内容和页脚。对于小型设备,我想保持这个顺序,在桌面上我想将页眉和页脚移动到侧边栏。
使用浮点数实现:http://codepen.io/anon/pen/jqrZby
标记
<div class="page">
<div class="top"></div>
<div class="content"></div>
<div class="bottom"></div>
</div>
CSS
.page {
border: 2px solid black;
padding: 1em;
}
.page:after {
content: "";
display: block;
clear: both;
}
.page > * {
margin-bottom: 1em;
}
.top {
border: 2px solid red;
height: 100px;
}
.content {
border: 2px solid blue;
height: 400px;
}
.bottom {
border: 2px solid green;
height: 200px;
}
@media screen and (min-width: 800px) {
.content {
width: 66%;
float: left;
}
.top, .bottom {
width: 33%;
float: right;
}
}
我正在尝试使用内容和侧边栏之间固定间距的 flexbox 找到解决方案。有人知道这是否可能吗?
【问题讨论】: