[英]How do I keep floated child divs from wrapping?
I'm trying to make a carousel type control that allows a user to pick radio button that's within one of many div elements. 我正在尝试制作一个轮播类型控件,该控件允许用户选择许多div元素之一内的单选按钮。 The idea is to have 20 or so 150px divs that contain radio buttons.
这个想法是让20个左右的150px div包含单选按钮。 I don't want those 20 divs to wrap once they reach the right side of the container.
我不希望那20个div一旦到达容器的右侧就进行包装。 I tried setting the container overflow to hidden but that didn't work.
我尝试将容器溢出设置为隐藏,但这没有用。 The basic html layout is
基本的html布局是
<div class="scheduler">
<div class="scheduler-inner">
<div class="item">...</div>
<div class="item">...</div>
<div class="item">...</div>
<div class="item">...</div>
...<div class="item">...</div>
</div>
<a class="scheduler">...</a>
<a class="scheduler">...</a>
</div>
I'm really just looking for some CSS guidance. 我真的只是在寻找一些CSS指导。 I don't want to have a scroll bar on
.scheduler-inner
and I will use javascript to move the .item
left or right on the click of the anchors. 我不想在
.scheduler-inner
上有滚动条,而是使用javascript在单击锚点时向左或向右移动.item
。 How should .scheduler-inner
be styled? .scheduler-inner
应该如何设置样式? I have 我有
.scheduler-inner { overflow:hidden; }
.scheduler-inner > div { float:left; width:10em; }
but they wrap as soon as it hits the edge of .scheduler-inner
. 但是一旦到达
.scheduler-inner
的边缘,它们就会自动包装。
What you need isn't floating but the style white-space: nowrap;
您需要的不是浮动的,而是
white-space: nowrap;
的样式white-space: nowrap;
Apply the nowrap on your container and set your items to display inline. 将nowrap应用到您的容器上,并将项目设置为内联显示。 Refer to the jsfiddle below.
请参阅下面的jsfiddle。
Here is a jsfiddle: http://jsfiddle.net/of5dmjux/ 这是一个jsfiddle: http : //jsfiddle.net/of5dmjux/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.