Высота CSS: 100% работает, только если родительский элемент имеет явно определенную высоту.Например, это будет работать должным образом:
td {
height: 200px;
}
td div {
/* div will now take up full 200px of parent's height */
height: 100%;
}
Поскольку кажется, что ваш <td>
будет переменной высоты, что, если вы добавили нижний правый значок с абсолютно позиционированным изображением, например так:
.thatSetsABackgroundWithAnIcon {
/* Makes the <div> a coordinate map for the icon */
position: relative;
/* Takes the full height of its parent <td>. For this to work, the <td>
must have an explicit height set. */
height: 100%;
}
.thatSetsABackgroundWithAnIcon .theIcon {
position: absolute;
bottom: 0;
right: 0;
}
С разметкой ячейки таблицы, например, так:
<td class="thatSetsABackground">
<div class="thatSetsABackgroundWithAnIcon">
<dl>
<dt>yada
</dt>
<dd>yada
</dd>
</dl>
<img class="theIcon" src="foo-icon.png" alt="foo!"/>
</div>
</td>
Редактировать: используя jQuery для установки высоты div
Если вы сохраните <div>
как дочерний элемент <td>
, этот фрагмент jQuery правильно установит свою высоту:
// Loop through all the div.thatSetsABackgroundWithAnIcon on your page
$('div.thatSetsABackgroundWithAnIcon').each(function(){
var $div = $(this);
// Set the div's height to its parent td's height
$div.height($div.closest('td').height());
});