更新于2018
确保您的表包含
table该类。这是因为Bootstrap4表是“选择加入”的,因此
table必须有意将类添加到表中。
Bootstrap 3.x还具有一些CSS来重置表单元,以使它们不会浮动。
table td[class*=col-], table th[class*=col-] { position: static; display: table-cell; float: none;}我不知道为什么Bootstrap 4 alpha并不是这样,但是它可能会在最终版本中重新添加。添加此CSS将有助于所有列使用
thead..中设置的宽度。
UPDATE(自Bootstrap 4.0.0起)
现在,Bootstrap 4是flexbox,添加时,表格单元将不会采用正确的宽度
col-*。一种解决方法是使用
d-inline-block表格单元格上的类来防止默认的display:flex列。
BS4中的另一种选择是使用宽度大小的utils类…
<thead> <tr><th >25</th><th >50</th><th >25</th> </tr></thead>
最后,您可以
d-flex在表格行(tr)和
col-*列的网格类(th,td)上使用…
<table > <thead> <tr > <th >25%</th> <th >25%</th> <th >50%</th> </tr> </thead> <tbody> <tr > <td >..</td> <td >..</td> <td >..</td> </tr> </tbody> </table>



