Why do Twitter Bootstrap tables always have 100% width?

前端 未结 6 598
南方客
南方客 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:26

    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:

...

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

提交回复
热议问题