Bootstrap 3 表,使用滚动条以 px 为单位设置固定列宽 [英] Bootstrap 3 table, set fixed column width in px with scrollbar

查看:25
本文介绍了Bootstrap 3 表,使用滚动条以 px 为单位设置固定列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Bootstrap 3 项目中,我需要一个以 px 为单位的固定列宽的表格.我的表中的每个

都有 style=##px 但它没有分配它.我试过将 style="width:auto; overflow: scroll;" 添加到表格中,但它不起作用.还尝试删除我桌子上的每个班级,但列不会增长.

I need a table with fixed column widths in px on my Bootstrap 3 project. Every <th> in my table <table id="items" class="table table-striped table-condensed"> has style=##px but its not assigning it. I've tried adding style="width:auto; overflow: scroll;" to the table but it does't work. Also tried removig every class on my table but colums wont grow.

请帮忙!

推荐答案

您可以指定一个

部分:

You could specify a <colgroup> section:

<table>
    <colgroup>
        <col span="1">
        <col span="1">
    </colgroup>
    ...
</table>

... 然后在 CSS 中设置列​​的宽度:

... and then set the width of your columns in CSS:

col {
    width:200px;
}

如果您在 table 元素上使用 bootstrap .table 类,您还需要将表格的宽度设置为 auto.

If you are using the bootstrap .table class on the table element, you will also need to set the width of your table to auto.

请参阅此 jsfiddle.

这篇关于Bootstrap 3 表,使用滚动条以 px 为单位设置固定列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆