[英]Float left divs going to next line
I have something similar to below: 我有类似下面的内容:
<div style="float:left;margin-left:5px;">Test</div>
The issue is that I need to have this div repeat multiple times. 问题是我需要多次重复此div。 If it repeats to many times, instead of forcing you to scroll right to see the rest of it (like I want it to), it instead goes down to the next line.
如果它重复多次,而不是强迫你向右滚动以查看剩下的部分(就像我想要的那样),而是向下移动到下一行。
Example of the issue: http://jsfiddle.net/ruh7z/1/ 问题示例: http : //jsfiddle.net/ruh7z/1/
Any help with this would be great, thanks 对此有任何帮助都很棒,谢谢
That behavior is exactly what floating is supposed to do. 这种行为正是浮动应该做的事情。 If you use
table-cell
for your display
style, that may give you more of what you're expecting. 如果您使用
table-cell
作为display
样式,那么可能会为您提供更多您期望的内容。 Note that you'll have to use padding instead of margins if you use table-cell
. 请注意,如果使用
table-cell
则必须使用填充而不是边距。
.container div
{
display: table-cell;
padding-left: 5px;
}
Here's a sample of this in use. 以下是使用中的示例 。
put the div's in a "fixed width" container div and prevent overflow. 把div放在一个“固定宽度”容器div中,防止溢出。 then have buttons or whatever at each end of the container div to "slide" the child divs left or right.
然后在容器div的每一端都有按钮或任何东西,以“向左或向右”滑动子div。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.