【发布时间】:2016-07-19 21:50:20
【问题描述】:
我想知道如何设计三列 div 布局,其尺寸可调节,如在图像中显示。
当桌面大小 (770px) 第一列有两个 div 而其他列有一个 div。
当平板电脑大小 (600px) 第一列有三个 div 而其他有一个 div。它有两列。
当移动尺寸(小于 600 像素)时,所有 div 都有一列。
请在图片中找到带有颜色的订单。这是没有任何适当样式的示例代码。
HTML:
<div class="body">
<div class="c1">blue</div>
<div class="c2">pink</div>
<div class="c3">green</div>
<div class="c4">yellow</div>
</div>
CSS:
@media only screen and (min-width: 0px) {
.c1 { width:100%; }
.c2 { width:100%; }
.c3 { width:100%; }
.c4 { width:100%; }
}
@media only screen and (min-width: 600px) {
.c1 { width:25%; }
.c2 { width:25%; }
.c3 { width:75%; }
.c4 { width:25%; }
}
@media only screen and (min-width: 768px) {
.c1 { width:25%; }
.c2 { width:25%; }
.c3 { width:50%; }
.c4 { width:25%; }
}
我用 CSS 中的 order 属性尝试了这个,但它不能正常工作。
【问题讨论】:
-
感谢您提供代码。是否需要旧版浏览器支持?你需要几岁?
-
没问题。非常感谢您的回复。