I have a table that should always occupy a certain percentage of the height of the screen. Most lines have a fixed height, but I have one line that needs to be stretched to fill the available space. If the contents of the cell in this row overflows the desired height, I will like the contents for the clip using overflow: hidden.
Unfortunately, tables and rows do not take into account the max-height property. (This is in the W3C specification). When there is too much text in the cell, the table becomes higher, instead of sticking to the specified percentage.
I can make the table cell behave if I specify a fixed height in pixels for it, but that defeats the goal of auto-stretching to fill the free space.
I tried using divs but can't find the magic formula. If I use divs with display: table ,: table-row and: table-cell, divs act just like a table.
Any tips on how I can simulate the max-height property on a table?
<head> <style> table { width: 50%; height: 50%; border-spacing: 0; } td { border: 1px solid black; } .headfoot { height: 20px; } #content { overflow: hidden; } </style> </head> <body> <table> <tr class="headfoot"><td>header</td></tr> <tr> <td> <div id="content"> put lots of text here </div> </td> <tr> <tr class="headfoot"><td>footer</td></tr> </table> </body>
html css html-table table
ccleve Aug 12 '11 at 19:59 2011-08-12 19:59
source share