I have a table with rows that need to be constant height. (Also width--but table-layout:fixed
seems to solve this.) The <tr>
s have <div>
s inside them, and they need to occupy 100% of the height of their cells. If the contents of the <div>
goes over, there needs to be a scrollbar. If it goes under, it still needs to occupy the full row.
Here's some minimal code:
<table border="1" width="200" style="table-layout:fixed;"><tbody>
<tr style="height:100px;">
<td>
<div style="height:100%; overflow:scroll; background-color:#cdf;">
abcdefghijklmnopqrstuvwxyzabcdefg<br/>abc<br/>abc<br/>abc<br/>abc<br/>abc
</div>
</td>
</tr>
<tr style="height:100px;">
<td>
<div style="height:100%; overflow:scroll; background-color:#fcc;">
abc
</div>
</td>
</tr>
But this isn't working in either case: if the contents of the <div>
are too long, it grows the cell and doesn't bother to use the scrollbar. If the contents are too short, it doesn't occupy the whole row. Any thoughts on a browser-independent way to establish a <tr>
as having a single, hard-set size? Also, please keep in mind that the actual contents of the <div>
s are dynamic, and I don't know them ahead of time. Thanks.