当上面 DIV 的高度大于 X 时,浮动 div 会下降
css:
.listingContainer {
margin:auto;
overflow:hidden;
padding:0 0 16px 16px;
width:660px;
}
.listingItem {
float:left;
margin:0 2% 3% 3%;
min-height:250px;
width:44.999%;
}
html:
<div class="listingContainer">
<div class="listingItem">
<p>Some Content</p>
</div>
<div class="listingItem">
<p>Some Content</p>
</div>
<div class="listingItem">
<p>Some Content</p>
</div>
</div>
如果任何给定的“listingItem”DIV 中的内容变得太大,则正下方的 div 将下降到下一行。
内容看起来像:
[1] [2]
[3] [4]
[5] [6]
但如果一个 div 中有 1 个额外的段落,而不是错开 div,它会被推到下一行:
[1] [2]
[4]
[3] [5]
[6]
这可能按预期工作,但我该如何解决这个问题?抱歉,无法提供实时页面。
有什么想法吗?
谢谢
css:
.listingContainer {
margin:auto;
overflow:hidden;
padding:0 0 16px 16px;
width:660px;
}
.listingItem {
float:left;
margin:0 2% 3% 3%;
min-height:250px;
width:44.999%;
}
html:
<div class="listingContainer">
<div class="listingItem">
<p>Some Content</p>
</div>
<div class="listingItem">
<p>Some Content</p>
</div>
<div class="listingItem">
<p>Some Content</p>
</div>
</div>
If the content in any given "listingItem" DIV becomes too great, the div directly below will drop to the NEXT row.
the content looks like:
[1] [2]
[3] [4]
[5] [6]
but if a div has say 1 extra paragraph in, rather than stagger the divs, it is pushed to the next row:
[1] [2]
[4]
[3] [5]
[6]
this isProbably working as intended, but how can i fix this? can't provide a live page sorry.
any ideas?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你在每一行中添加一个带有清除两者的div,或者一个行容器div,它会起作用,但是,就像dclowd9901所说,表格内容应该在表格中,这就是它的用途!
if you add a div with clear both, or a row container div to each row it would work, however, like dclowd9901 says, tabular content should be in a table, thats what its for!
像这样的事情让我很痒:
width:44.999%
有什么特殊原因你不能只使用(喘气!)表格吗?我只是好奇,因为在大多数设计中,您的设计似乎实际上会受益于表格布局。
Things like this make me itch:
width:44.999%
Is there any particular reason you can't just use a (gasp!) table? I'm only curious because, of most designs out there, yours seems like it would actually benefit from a table layout.