Reputation: 21
I have a 100% width table that fits the entire html body. Each <td>
has a fixed width, which in sum exceeds the body width.
The HTML:
<table>
<tr>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
etc... etc...
<td>test</td>
<td>test</td>
<td>last one in the line</td>
</tr>
</table>
Simple CSS to demonstrate:
table td {
width: 100px;
border: solid 1px black;
white-space: nowrap;
}
The problem is that instead of overflowing the body and showing a horizontal scrollbar, the table reduces each <td>
's width to fit the document.
How can I force the width and show a scrollbar?
Upvotes: 2
Views: 1837
Reputation: 1414
use use min-width, as below
table td {min-width: 100px; border: solid 1px black;white-space: nowrap;}
Upvotes: 2
Reputation: 33153
Use min-width
instead to force the cell to always keep the width.
table td {
min-width: 100px;
border: solid 1px black;
white-space: nowrap;
}
Demo: http://jsfiddle.net/H55Se/3/
Upvotes: 4