jquery - 带有 div 的内联列表无法使用 Twitter Bootstrap 正确显示

标签 jquery html css twitter-bootstrap

我正在尝试创建一个无序列表来显示一系列 140px x 140px 的 div,并通过 jquery 根据数组中的元素数动态填充。

但是它们并没有与我的代码一起显示在水平直线上,我想解决这个问题。

HTML

<div class="row">
    <div class="col-md-10 col-md-offset-1">
        <div class="product-list">
            <ul class="list-inline">
            </ul>
        </div>
    </div>
</div>

Jquery 填充列表:

JQUERY

productLoad: function() {
    for (var i = 0; i < state.greens.length; i++) {
        $(".product-list ul").append("<li><div class='product'><p> " + state.greens[i].name + " </p></div></li>");
    }
},

函数 productLoad 是名为 display 的对象的一部分,由 display.productLoad() 调用;

我为 .product 使用以下 CSS:

CSS

.product {
width: 140px;
height: 140px;
background-color: #006B3C;
opacity: 0.6;
padding: 5px;
}

.product p {
color: #fff;
text-transform: uppercase;
font-size: 16px;
text-align: center;
}

我怀疑我的问题是 CSS,但我不确定是什么导致了对齐错误。一些正方形渗入它下面的正方形,它们不像我想要的那样在一条直线上。

您可以在此处查看结果:superfood picker

滚动到显示“单击产品以转到其详细信息页面”的部分,您将看到未对齐的 div 列表。

最佳答案

vertical-align: top 添加到 .list-inline>li 的 CSS 中

关于jquery - 带有 div 的内联列表无法使用 Twitter Bootstrap 正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32208185/

相关文章:

jquery - 使用 Jquery 将 css 应用于除一个元素之外的所有元素

javascript - 使用javascript发送post请求

css - 在 R Shiny 应用程序中调整flexdashboard仪表的布局?

Javascript 事件 'mouseenter' 第一次触发两次 - Meteor

javascript - jQuery/CSS : Changing the height and width attributes of an image when clicked

html - 如何在bootstrap 3中制作垂直中间

javascript - 解绑后使用绑定(bind)

html - 在 Div 中真正居中文本

html - 设置html5元素之间的空间

jquery - 类确实通过 jquery 添加,但不起作用