html - 如何更改 HTML 表格的宽度?

标签 html css html-table

<分区>


关闭 7 年前

我这样声明一个表:

<div class="row">
     <div class="module span12">
           <section class="module">
                <table class="table table-striped table-bordered table-condensed">

                echo "<tr><td style='color: white; background-color: black;'><strong>Overall inventory breakdown</strong></td>";
                echo "<td style='text-align: center; color: white; background-color: black;'><strong></strong></td>";
                echo "<td style='text-align: center; color: white; background-color: black;'><strong>Ist</strong></td>";
                echo "<td style='text-align: center; color: white; background-color: black;'><strong>Soll</strong></td></tr>";

                </table>    
          </section>
     </div>
</div>

现在,表格和整个页面一样宽。但我希望它更小。

我已经尝试过几种 CSS 变体,例如在每个 td 上设置 width 值,但对我来说没有任何效果。有帮助吗?

最佳答案

这似乎是一个 Bootstrap 问题。

.table {
    /* width: 100%; */
    width: auto;
}

了解浏览器的文档检查工具。它使发现此类事物的来源变得微不足道。

关于html - 如何更改 HTML 表格的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37864149/

上一篇:html - 如何使背景图像适合屏幕?

下一篇:html - CSS 动画不起作用?

相关文章:

html - 较大可点击区域内的链接(仅限 CSS)

javascript - 如何在 react 中设置单选按钮的默认值?

html - 响应式电子邮件模板定位问题

css - 为什么这在 Firefox、Chrome 和 IE 中的工作方式不同?

html - 在表格旁边 float 一个 Div

javascript - 是否有可能通过 jQuery 中的索引号获取父元素?或者还有其他办法吗?

javascript - CSS 幻灯片在单击之前不显示图像

html - 表格填充/边距/任何

css - 除非我将标题的宽度设置为 100%,否则固定位置抛出我的标题居中为什么?

css - 复选框表 - 列宽相等