When the height
property is applied to table cells (whether using native tags like <td>
or CSS enabled like display: table-cell
), it is interpreted as a minimum value.
A table cell's height will expand as needed to accommodate the content, and that will in turn, determine the height of the table row containing the cell.
Reference: http://www.w3.org/TR/CSS2/tables.html#height-layout
How to Fix a Height in a Table Cell
One way of set a fixed height within a table cell is by using a wrapper for the table cell's content:
<div id="table">
<div id="table-cell1">
<div class="inner-cell">table cell 1</div>
</div>
<div id="table-cell2">
<div class="inner-cell">table cell 2
<br/>Table
<br/>Cell</div>
</div>
</div>
and apply the following CSS:
body {
margin: 0
}
#table {
display: table;
width: 100%;
height: 30px;
/* ignored */
}
#table-cell1 {
display: table-cell;
width: 80px;
background-color: yellow;
}
#table-cell2 {
display: table-cell;
background-color: gray;
color: white;
}
.inner-cell {
border: 1px dashed blue;
height: 30px;
overflow: auto; /* optional: if needed */
}
The trick is to set a fixed (or max) height value for the block level container .inner-cell
.
You can also set the overflow property if you need scroll bars and so on.
See demo fiddle: http://jsfiddle.net/audetwebdesign/mNcm5/