Why do Twitter Bootstrap tables always have 100% width?

前端 未结 6 601
南方客
南方客 2021-01-29 23:47

Suppose this markup:

No mather how many cells I have, the table is always 100% w

6条回答
  •  遇见更好的自我
    2021-01-30 00:14

    Bootstrap 3:

    Why fight it? Why not simply control your table width using the bootstrap grid?

This will create a table that is half (6 out of 12) of the width of the containing element.

I sometimes use inline styles as per the other answers, but it is discouraged.

Bootstrap 4:

Bootstrap 4 has some nice helper classes for width like w-25, w-50, w-75, w-100, and w-auto. This will make the table 50% width:

Here's the doc: https://getbootstrap.com/docs/4.0/utilities/sizing/

提交回复
热议问题