Bootstrap 4 table with one column larger than others

bootstrap 4 table column width fit content
bootstrap scrollable table
bootstrap 4 table stack columns
bootstrap 4 table minimum column width
bootstrap 4 table auto width column
bootstrap 4 table column width chrome
bootstrap 4 table resize
bootstrap 4 column width

I've created a Bootstra4 table with multiple columns. One of them needs to be larger than the others, in order to fit more text. I'd like to set the minimum width of the larger column, and let Bootstrap4 figure out the size of other columns. I've been trying different things, but I can't find a way of setting the width of the desired column. Appreciate any hints. Thanks.

Lets assume that column 11 should be larger.

<script  type="text/javascript">
  $(document).ready(function() {
        "lengthMenu": [ [10, 20, 30, -1], [10, 20, 30, "All"] ]
  } );

<table id="mytable" class="table table-striped table-hover table-bordered">
      <th>column 1, default size</th>
      <th>column 2, default size</th>
      <th>column 3, default size</th>
      <th>column 4, default size</th>
      <th>column 5, default size</th>
      <th>column 6, default size</th>
      <th>column 7, default size</th>
      <th>column 8, default size</th>
      <th>column 9, default size</th>
      <th>column 10, default size</th>
      <th>column 11, 15% size/th>
      <th>column 12, default size</th>
      <th>column 13, default size</th>
      <th>column 14, default size</th>
      <th>column 15, default size</th>
      <th>column 16, default size</th>
      <th>column 17, default size</th>
      <th>column 18, default size</th>
      <td>column 1, default size</td>
      <td>column 2, default size</td>
      <td>column 3, default size</td>
      <td>column 4, default size</td>
      <td>column 5, default size</td>
      <td>column 6, default size</td>
      <td>column 7, default size</td>
      <td>column 8, default size</td>
      <td>column 9, default size</td>
      <td>column 10, default size</td>
      <td>column 11, 15% size</td>
      <td>column 12, default size</td>
      <td>column 13, default size</td>
      <td>column 14, default size</td>
      <td>column 15, default size</td>
      <td>column 16, default size</td>
      <td>column 17, default size</td>
      <td>column 18, default size</td>

A correct way of doing this is using flexbox on the table. more info about flexbox here.

You could also use col-x being x=1,2,3...,12 (column width) on the table columns. More info about this way here

Hope that solves your problem!

Tables · Bootstrap, Documentation and examples for opt-in styling of tables (given their prevalent use in Just add the base class .table to any <table> , then extend with custom styles or our Add .table-hover to enable a hover state on table rows within a <​tbody> . for instance) by using values with higher precision for these comparisons. A basic Bootstrap 4 table has a light padding and horizontal dividers. The .table class adds basic styling to a table: The .table-striped class adds zebra-stripes to a table: The .table-bordered class adds borders on all sides of the table and cells: The .table-hover class adds a hover effect (grey background color) on table rows:

Use a div in the eleventh th cell and set its min-width.

Grid system · Bootstrap, This padding is then counteracted on the rows with negative margins. aspects of the Bootstrap grid system work across multiple devices with a handy table. Auto-layout for flexbox grid columns also means you can set the width of one <​div class="row"> <div class="col"> 1 of 3 </div> <div class="col-6"> 2 of 3 (wider)​  The Bootstrap 4 grid system has five classes:.col-(extra small devices - screen width less than 576px).col-sm-(small devices - screen width equal to or greater than 576px).col-md-(medium devices - screen width equal to or greater than 768px).col-lg-(large devices - screen width equal to or greater than 992px)

I found a solution that works for my case, in Set min-width in HTML table's <td>:

<td style="min-width:100px"> 

How the Bootstrap 4 Grid Works, __Can I make one Column wider than the others? I will address Grid questions like these in a little while. But, first I want to take a step  When the webpage is divided into two equal columns, and the content inside the columns starts to overflow, the columns become scrollable. However, by doing some small modifications, the columns can be fixed. This article will demonstrate how to keep one column fixed, and the other column scrollable. Syntax: To fixed the column make not scrollable.

If people are still looking for solution. This worked for me

table {
  table-layout: fixed;

Learn the Bootstrap 4 Grid System in 10 Minutes, Table of Contents The Bootstrap 4 grid consists of containers, rows and columns. If you place other elements inside the row along with columns you will not If you add two columns, they will each take 1/2 from the width. .col-sm for larger mobile phones (devices with resolutions ≥ 576px); .col-md for  The Bootstrap 4 grid system has five classes: .col- (extra small devices - screen width less than 576px) .col-sm- (small devices - screen width equal to or greater than 576px) .col-md- (medium devices - screen width equal to or greater than 768px) .col-lg- (large devices - screen width equal to or greater than 992px)

HTML Tables: All there is to know about them, They consist of rows and columns and are often used on websites for the effective By default, all table cells are spaced out from one another by 2px. If the displays are wider than anticipated, much of the display is will be  By default, the Bootstrap 4 grid consists of 12 columns. You can select any size from 1 to 12 for your column. If you want 3 equal columns, you can use .col-4 for each one (because 3*4 cols each = 12).

table-layout, In order for a value of fixed to have any effect, the table's width has to be set to something other than auto (the default for the width property). When table-​layout: fixed is applied, the content no longer dictates the layout, but instead uses any defined widths from the table's first row to define column widths. Bootstrap Grid Table Overview. Bootstrap includes a great mobile-first flexbox grid system for establishing formats of any contours and proportions . It is simply founded on a 12 column configuration and possesses several tiers, one for every media query variation.

Fixed Table Layouts, There is a CSS property for tables that, it seems to me, Set the width of those, and the rest of the table follows. It's a Well, unless YOU force it wider by, setting the cells wider (combined) than the table is wide. overflow: hidden; text-​overflow: ellipsis; } /* Column widths are based on these cells */ .row-ID  It follows many traditional techniques like highlighting the table headers and keeping one column larger than the others. But I’m most impressed with the varying color choices that blend so well together. It’s almost like these tables have a few different headers, and they all grab your attention for different reasons. 10. Flexbox Pricing

  • Apart from your described problem, you're missmatching <td> with </th> inside <tbody>
  • @FabianSchöner. Thanks. I've fixed the example in my text. It was a typo when I wrote the question , but this part of my code is right.
  • Thanks for the flexbox info. I needed to keep it simpler now, using <td style="min-width:100px">
  • Thanks. It works for me without a div: <td style="min-width:100px">