richey
richey

Reputation: 3958

Scrolling table cell - but only if necessary

I'd like to display a table that just consists of 2 cells really - at the left, there is a (fixed size) image, at the right, a list of items that is filled dynamically, meaning that it will usually be longer than the height of the image - so it should have a scrolling feature.

That works fine so far - apart from the fact that there are scrollbars even if the "list" is empty. Is there a way to display the scrollbars only if they are necessary? I know I want much. 8-) ..

This is my current code:

<div style="width:100%; height:400px;">
    <div id="image" style="float:left; width:540px; height:400px"></div>
    <div id="items" style="float:left; height:400px; overflow:scroll; width:20%;"></div>
</div>

Upvotes: 0

Views: 98

Answers (1)

Minko Gechev
Minko Gechev

Reputation: 25672

You can make the container scrollable only when it's necessary by using overflow: auto;.

Here is an example: http://jsfiddle.net/ZHEHT/

Upvotes: 1

Related Questions