This question has been asked several times, but none of the answers provided seem to help me:
See this in action here: http://jsfiddle.net/BlaM/bsQNj/2/
I have a "dynamic" (percentage based) layout with two columns.
.grid { width: 100%; box-sizing: border-box; } .grid > * { box-sizing: border-box; margin: 0; } .grid .col50 { padding: 0 1.5%; float: left; width: 50%; }
In each of these columns I have a table that is supposed to use the full column width.
.data-table { width: 100%; } .data-table td { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
My problem is that some of the columns in that table have content that needs to be truncated to fit in the given width of the table. That does not happen, though. I get two tables that are overlaying each other.
Requirements:
What I tried:
Related Questions:
To set the table width in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property width.
The trick is to use the CSS property table-layout. It can take three values: auto , fixed , and inherit . The normal (initial) value is auto , which means that the table width is given by its columns and any borders. In other words, it expands if necessary.
Using table-layout: fixed as a property for table and width: calc(100%/3); for td (assuming there are 3 td 's). With these two properties set, the table cells will be equal in size.
To manipulate the height or width of an entire table, place the size attribute (either "WIDTH=" or "HEIGHT=") within the <TABLE> code. To manipulate individual cells, place the size attribute within the code for that cell.
you need to add the table-layout property:
table-layout: fixed;
also include width=100% in the table HTML tag, not just the style tag.
http://jsfiddle.net/reeK5/
Maybe you'll be interested in a max-width: 0;
hack I've discovered.
It has some limits, we should use CSS tables instead of HTML, but it works:
.leftBlock { width: 100%; max-width: 0; word-wrap: break-word; overflow: hidden; } .rightBlock { width: 200px; max-width: 200px; min-width: 200px; }
http://jsfiddle.net/CyberAP/NUHTk/103/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With