jquery - 内联显示 div 元素

标签 jquery html css

我在我的 DOM 中使用 jQuery kinetic 插件。我用它来水平滚动一组 div。 div 滚动很好,但是,元素只在一行中!我试图让 div 逐行显示。下面是 HTML 元素层次结构。

<div id="item-tab-1">
    <!-- Item List -->
    <div id="item-list-section">
        <div class="item">
             <!-- Item Price -->
             <div class="item-price">
                  <h4>25.00</h4>
             </div>

             <!-- Item Name -->
             <div class="item-name">
                  <h4>DRINK</h4>
             </div>
        </div>
        <div class="clear"></div>
    </div>

    <div class="clear"></div>
</div>

使用 jQuery 代码,“Item”类元素被复制了大约 100 次。所以在运行时,根据脚本可以有 100 多个元素。以下代码用于激活 kinetic 插件。

$('#item-list-section').kinetic({y:false,x:true});

下面是我在元素中使用的 CSS。

#item-list-section {
    width: inherit;
    height: 423px;
    overflow: hidden;
    white-space: nowrap;
    float: none;
    display: table;

}

#item-tab-1{
    cursor: move;
}


.item {
    height: 70px;
    width: 80px;
    margin: 15px 0px 0px 20px;
    float: left;
    border-radius: 10px;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
    cursor: pointer;
    box-shadow: 0px 0px 10px rgb(75, 75, 75);
    display: -webkit-inline-box;
}

如何使用 CSS 完成此操作。我无法逐行显示元素 bt 保持滚动能力效果! float 不在表中,因为使用 float 关键字时,kinetic 不起作用。

下面是它现在如何显示的图像。

enter image description here

最佳答案

您是否尝试修改此 - $('#item-list-section').kinetic({y:false,x:true});?

我不知道你的插件,但似乎有一个选项可以“打开”垂直滚动(或者也可能是垂直布局)。将该行设置为 -

$('#item-list-section').kinetic({y:true,x:false});

编辑:

修改这个 -

#item-list-section {
width: inherit;
height: 423px;
overflow: hidden;
white-space: nowrap;
float: none;
display: table;
}

对此——

#item-list-section {
width: inherit;
height: 423px;
overflow: scroll;
white-space: nowrap;
float: none;
display: table;
}

fiddle - http://jsfiddle.net/GHcb3/

关于jquery - 内联显示 div 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17691125/

相关文章:

javascript - 使用 Jasmine 测试套件测试点击事件

jquery - 使用有 Backbone 的 promise

javascript - jQuery - 在用户点击模式上的是按钮后返回启动画面

CSS 背景图像和填充

javascript - 在 JQuery (Javascript) 中构建迷你游戏

javascript - 带有搜索按钮的jquery下拉框

javascript - 为什么原型(prototype)和 jquery 之间仍然存在冲突?

javascript - ThreeJS高亮/投影仪

php - XML 中的 HTML 标记`

javascript - 向上滚动时动画标题消失