Use one of the following classes to manipulate the width of the columns.
Detailed documentation and more examples of Bootstrap table column width you can find in our Bootstrap Table Responsive Docs and Bootstrap Tables Docs.
Use one of the following classes to manipulate the width of the columns.
Add
.w-auto
class to the
table
element to set an auto width to the table column.
The width of the columns will automatically adjust to the content of the column. That means it will always take a minimum width required to present its content.
# | Name | Surname | Country | City | Position | Age |
---|---|---|---|---|---|---|
1 | Kate | Moss | USA | New York City | Web Designer | 23 |
2 | Anna | Wintour | United Kingdom | London | Frontend Developer | 36 |
3 | Tom | Bond | Spain | Madrid | Photographer | 25 |
4 | Jerry | Horwitz | Italy | Bari | Editor-in-chief | 41 |
5 | Janis | Joplin | Poland | Warsaw | Video Maker | 39 |
6 | Gary | Winogrand | Germany | Berlin | Photographer | 37 |
7 | Angie | Smith | USA | San Francisco | Teacher | 52 |
8 | John | Mattis | France | Paris | Actor | 28 |
9 | Otto | Morris | Germany | Munich | Singer | 35 |
Use
.th-lg
or
.th-sm
class to set a minimal width of a table column.
.th-lg
class gives
9 rem
of the minimal width of the column and
.th-sm
class gives
6 rem
.
You have to add
.th-lg
or
th.sm
class to the
<th>
element within the
<thead>
.
Resize the browser window to see the effect.
.th-lg
- 9 rem minimal width of the column
# | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
---|---|---|---|
1 | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
2 | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
3 | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
.th-sm
- 6 rem minimal width of the column
# | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
---|---|---|---|
1 | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
2 | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
3 | Lorem ipsum dolor | Lorem ipsum dolor | Lorem ipsum dolor |
Add
.table-fixed
class to the
table
element to set a fixed width to the all columns of the table.
A .table-fixed
get a table a lot sturdier and more predictable with property/value in place.
When you are use .table-fixed
layout of your table is based on the first row.
# | Name | Surname | Country | City | Position | Age |
---|---|---|---|---|---|---|
4 | Jerry | Horwitz | Italy | Bari | Editor-in-chief | 41 |
5 | Janis | Joplin | Poland | Warsaw | Video Maker | 39 |
6 | Gary | Winogrand | Germany | Berlin | Photographer | 37 |
7 | Angie | Smith | USA | San Francisco | Teacher | 52 |
8 | John | Mattis | France | Paris | Actor | 28 |
9 | Otto | Morris | Germany | Munich | Singer | 35 |
With class .text-nowrap
you can specific how white-space inside an table is handled.
Sequences of white space are preserved. Lines are broken at newline characters, at br
, and as
necessary to fill
line boxes.
If you want use a .text-nowrap
you have to use div wrapper with .table-responsive
class
because your table will be broken on small on small screens.
For example here is table with text-nowrap
class:
# | Name | Surname | Country | City | Position | Age |
---|---|---|---|---|---|---|
1 | Kate | Moss | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 23 |
2 | Anna | Wintour | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 36 |
3 | Tom | Bond | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 25 |
4 | Jerry | Horwitz | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 41 |
5 | Janis | Joplin | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 39 |
6 | Gary | Winogrand | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 37 |
7 | Angie | Smith | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 52 |
8 | John | Mattis | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 28 |
9 | Otto | Morris | USA / The United Kingdom / China / Russia | New York City / Warsaw / Lodz / Amsterdam / London / Chicago | Web Designer /UX designer / Ul designer / JavaScript Developer | 35 |