html - 表格列垂直显示而不是水平显示 - Bootstrap

标签 html css twitter-bootstrap jsp

Image of problem

我正在使用 Bootstrap 类并尝试水平显示表格。我一直在网上搜索,但没有找到解决方案。

具体JSP页表的代码片段为:

        <table class="table table-striped table-hover">
            <thead>
            <tr class="bg-success">
                <th>Photo Thumb</th>
                <th>Product Name</th>
                <th>Category</th>
                <th>Condition</th>
                <th>Price</th>
                <th></th>
            </tr>
            </thead>
            <tbody>

            <c:forEach items="${products}" var="product">
                <tr>
                    <td><img src="<c:url value="/resources/images/${product.productId}.png" /> " alt="image"
                             style="width:100%"/></td>
                    <td>${product.productName}</td>
                    <td>${product.productCategory}</td>
                    <td>${product.productCondition}</td>
                    <td>${product.productPrice}</td>
                    <td><a href="<spring:url value="/productList/viewProduct/${product.productId}" />"
                    ><span class="glyphicon glyphicon-info-sign"></span></a></td>
                </tr>
            </c:forEach>

            </tbody>
        </table>

编辑 1 我添加的额外 CSS 如下:

.container-wrapper {
    height: 80%;
    margin: auto;
    margin-top: 80px;
    margin-bottom: 300px;
}

.table {
    table-layout: fixed;
    overflow: auto;
}

.table th {
    text-align: center;
}

.table td {
    text-align: center;
    background: whitesmoke;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

最佳答案

删除

.table td {
    display: block;
}

codepen example

在 css 中注释和取消注释 display 属性以查看它所产生的差异。

关于html - 表格列垂直显示而不是水平显示 - Bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43509142/

相关文章:

javascript - 我已经在 <a> 标签中设置了背景图像,现在我想通过使用内联 css 更改鼠标悬停事件上的图像

html - 表比 Bootstrap 列容器宽

css - css动画可以得到-moz-animation的简写吗?

CSS:如何在表格上指定最小宽度?

javascript - 有什么方法可以使用 Javascript 设置 Jquery UI Mobile 导航栏状态?

html - 适合窗口的图像网格

当模态隐藏时,jQuery选择器找不到 Bootstrap 的模态

html - 将选中的复选框从勾号更改为纯色背景色

css - 小屏幕上 3 个 div 的不同 flexbox 对齐方式

javascript - MediaElements.js YouTube 音频自动播放