Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap tables overflowing with long unspaced text

I'm using Bootstrap and I have a table with a few columns, the last of which sometimes has a long piece of text without spaces. I noticed that under certain screen sizes, the table would overflow its parent div and create ugly overlapping with its sibling table.

I played around with it and I think the problem has to do with the text being unspaced. I created a jsfiddle that demonstrates what I mean.

As you can see, the top leftmost table is well behaved and simply grows vertically to accommodate more text. However, the bottom left table leads to an overflow on the right due to the long unspaced text and the right column of the bottom left table winds up "under" its sibling.

Does anyone have any tips on how I can fix this so that the very long text gets clipped or partially split onto a new line?

like image 714
Richard Bender Avatar asked Aug 30 '12 11:08

Richard Bender


People also ask

How do I reduce the size of a bootstrap table?

HTML. Small table: To make the table smaller in size use the class table-sm along with the class table within the <table> tag. This reduces the cell padding to half. To make the dark table smaller in size use the combination of classes table, table-sm, and table-dark within the <table> tag.

How do I set the width of a bootstrap table?

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.

What is table striped in bootstrap?

.table-striped. Adds zebra-striping to any table row within <tbody> (not available in IE8) Try it. .table-bordered. Adds border on all sides of the table and cells.

Which table class makes the table more compact in bootstrap?

Small table. Add . table-sm to make tables more compact by cutting cell padding in half.


Video Answer


2 Answers

.the-table {     table-layout: fixed;     word-wrap: break-word; } 

Deprecated (i.e. word-wrap)

Add the following styles to your <table>

.the-table {     table-layout: fixed;     over-flow: break-word; } 

Then you can adjust your layout via-CSS as you wish.

like image 132
albertedevigo Avatar answered Sep 23 '22 15:09

albertedevigo


This works without forcing table layout to be fixed Just add it to td or any

.is-breakable {   word-break: break-word; } 
like image 35
Kate Kasinskaya Avatar answered Sep 24 '22 15:09

Kate Kasinskaya