Making a Bootstrap table column fit to content

前端 未结 7 2092
情话喂你
情话喂你 2021-01-30 02:40

I\'m using Bootstrap, and drawing a table. The rightmost column has a button in it, and I want it to drop down to the minimum size it needs to fit said button.

相关标签:
7条回答
  • 2021-01-30 03:41

    Kind of an old question, but I arrived here looking for this. I wanted the table to be as small as possible, fitting to it's contents. The solution was to simply set the table width to an arbitrary small number (1px for example). I even created a CSS class to handle it:

    .table-fit {
        width: 1px;
    }
    

    And use it like so:

    <table class="table table-fit">
    

    Example: JSFiddle

    0 讨论(0)
提交回复
热议问题