简体   繁体   English

使用滚动条防止div出现新字符串

[英]Preventing div from new string with scrollbar

I have a div with some image div in it. 我有一个div ,其中包含一些图像div

<div class="sliderscrollbar">
    <div class="scrollableimage"></div>
    <div class="scrollableimage"></div>
    <div class="scrollableimage"></div>
    <div class="scrollableimage"></div>
    <div class="scrollableimage"></div>
    <div class="scrollableimage"></div>
</div>

div.sliderscrollbar
{
    display: inline-block;
    width: 900px;
    height: 200px;
    overflow-x: scroll; 
}
div.scrollableimage
{
    display: inline-block;
    width: 200px;
    height: 120px;
    background: url('http://www.selectism.com/files/2014/12/Holiday-Gift-Guide-Stocking-Stuffers-feature-200x120.jpg') no-repeat;
}

Fiddle here The problem is that divs that doesn't suit it's width, move to next line. 这里小提琴的问题是,不适合它的宽度的div,移动到下一行。 However I expect them to be in 1 line because they are inline-block 但是我希望它们在一行中,因为它们是inline-block

You're missing the almighty white-space: nowrap statement for your container element. 您缺少容器元素的全能white-space: nowrap语句。

Demo: http://jsfiddle.net/575ora3r/1/ 演示: http//jsfiddle.net/575ora3r/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM