awestover89
awestover89

Reputation: 1763

Overflow and max-height

I am trying to set up a scrolling table with a maximum height, and to do that I have:

<table>
<tbody style="height: 300px; overflow:auto;">
//php for loop, populating table with <tr>s/<td>s
</tbody>
</table>

This works fine, but if there is only one or two rows they are stretched to fit the 300px height. I switched height to max-height but then the scroll bars never appeared, no matter how large the table got. Where am I going wrong?

Upvotes: 0

Views: 312

Answers (1)

banjokaboom
banjokaboom

Reputation: 134

I don't know why the tr's and td's are filling the height up when there are few, but you could do a couple things I think.

Try styling the cells to be a certain height, or even don't style anything to a height, and style the div that the table is in to a height. I've done the latter, and it works for me. The cells all stay a normal height, depending on whats in them.

Upvotes: 2

Related Questions