Reputation: 3383
I have a table with two columns, and I want the height of each row to be determined by the height of the content in the right column, so that cells in the left column will tend to get cut off vertically.
Can I do this in CSS? I've tried setting max-height=100%
on the left td
, as well as using a div
inside the left td
and setting max-height=100%
on that instead. But the rows still get sized to fit whichever cell is biggest, rather than ignoring the size of the left one.
Upvotes: 0
Views: 236
Reputation: 78676
You can set the div to position:absolute
with overflow:hidden
etc, and set some width
on the td
to prevent it from collapsing with the only absolute div inside.
table {
width: 200px;
}
td {
width: 50%;
}
td:first-child {
position: relative;
}
td:first-child > div {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
overflow: hidden;
}
<table border="1">
<tr>
<td>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</td>
<td>Lorem ipsum</td>
</tr>
</table>
Upvotes: 1