javascript - 使用滚动条防止 div 来自新字符串

标签 javascript jquery html css

我有一个 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 问题是不适合其宽度的 div 会移动到下一行。但是我希望它们在 1 行中,因为它们是 inline-block

最佳答案

您缺少用于容器元素的万能的 white-space: nowrap 语句。

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

关于javascript - 使用滚动条防止 div 来自新字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28023436/

相关文章:

javascript - OnClick 不起作用

jquery - 如何将 json 日期格式转换为以下 dd/mm/yyyy

jquery - 需要覆盖 CSS 背景色

HTML/CSS 鼠标悬停图像隐藏

html - 如何添加相当于 unicode 字符的 "alt"属性(在一个范围内)?

html - 使用 p-tableHeaderCheckbox 和 p-table 移动到下一页时,应取消选中标题中的“全选”复选框

javascript - 当您将鼠标悬停在图像的特定区域上时如何显示下拉菜单? (HTML, CSS)

javascript - PHP CodeIgniter - cookie 过期但页面仍然存在,该怎么办?

javascript - AngularJS $http.put 在 Firefox 或 Chrome 中不起作用。在 IE 中工作正常

JQuery live 或与 .change() 类似的东西?