【发布时间】:2013-12-23 01:37:40
【问题描述】:
在尝试排列放置在多行中的项目时遇到了一个奇怪的问题,每行包含 5 或 4 个项目(交替 5 个项目、4 个项目、5 个项目等......)。但是,在 480 像素的屏幕宽度下,无论每行有多少,布局都会简单地切换为 2 个项目宽。这会在 4 项行和 5 项行之间产生布局问题。当它们堆叠在一起时,4 行工作正常(2x2),但 5 行在盒子的末端有一个悬挂物品/空白点(2x2x1)。
4/5 行布局:
2x2 行布局(有悬挂物品问题)
HTML:
<section id="rowArea">
<div class="row fiveRow clearfix">
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
</div>
<div class="row fourRow clearfix">
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
</div>
<div class="row fiveRow clearfix">
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
<div class="rowItem"></div>
</div>
</section>
CSS:
/* Screen Width > 480px */
#rowArea {width:810px; height:auto; }
.row {height:100px; }
.fourRow {width:80%; padding:0 10%; }
.fourRow .rowItem {width:25%; height:100px; float:left; }
.fiveRow {width:90%; padding:0 5%; }
.fiveRow .rowItem {width:20%; height:100px; float:left; }
/* Screen Width < 810px */
#rowArea {width:100%; height:auto; }
/* Screen Width < 480px */
#rowArea {width:100%; height:auto; }
.row {height:100px; }
.fourRow, .fiveRow {width:100%; padding:0 0; }
.fourRow .rowItem, .fiveRow .rowItem {width:50%; height:100px; float:left; }
我如何重组这个/设置这个样式以消除 5 项行末尾的空白点?非常感谢任何帮助!
【问题讨论】:
-
是否可以让以下集合中的第一行占据该空白点,或者您希望将三个项目行分开?
-
我添加了问题的图片以进行澄清
标签: html css responsive-design css-float