为什么 Twitter Bootstrap 表格的宽度总是 100%? [英] Why do Twitter Bootstrap tables always have 100% width?

查看:26
本文介绍了为什么 Twitter Bootstrap 表格的宽度总是 100%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设这个标记:

<table class="table table-bordered" align="center"> 

不管我有多少个单元格,表格总是 100% 宽度.为什么?

No mather how many cells I have, the table is always 100% width. Why's that?

推荐答案

引导程序中的所有表格都根据其容器进行拉伸,您可以通过将表格放在 .span* 网格中轻松实现您选择的元素.如果你想删除这个属性,你可以创建你自己的表类,然后简单地将它添加到你想要用其中的内容展开的表中:

All tables within the bootstrap stretch according to their container, which you can easily do by placing your table inside a .span* grid element of your choice. If you wish to remove this property you can create your own table class and simply add it to the table you want to expand with the content within:

.table-nonfluid {
   width: auto !important;
}

您可以将此类添加到您自己的样式表中,然后简单地将其添加到您的表的容器中,如下所示:

You can add this class inside your own stylesheet and simply add it to the container of your table like so:

<table class="table table-nonfluid"> ... </table>

这样您的更改就不会影响引导样式表本身(您可能希望在文档中的其他地方有一个流动表格).

This way your change won't affect the bootstrap stylesheet itself (you might want to have a fluid table somewhere else in your document).

这篇关于为什么 Twitter Bootstrap 表格的宽度总是 100%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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