tags:

views:

43

answers:

2

Hi,

Why doesn't div with id "shouldHaveScrollBar" doesn't display a horizontal scrollbar:

<div style="overflow:hidden; 
            width: 300px; height: 300px; background-color:blue; color:white">

    <div>Some stuff</div>
    <div>Some other stuff"</div>
    <div id="shouldHaveScrollBar" 
         style="background-color:grey; 
                width: 100%; height: 100%; overflow-x:auto">
      <input type="text" size=200">
    </div> 
</div>

Thank you,

+4  A: 

Because your horizontal scroll bar is hidden in the y-overflow.

shouldHaveScrollBar is set to 100% height, which is 100% of it's parent, so it is 300px in height. Unfortunately, the other 2 divs "Some stuff", etc, push it down, meaning that your scroll bar at the bottom is hidden by the overflow:hidden of your parent div.

Change the height of shouldHaveScrollBar to 50% and you will see what I mean. Your height should probably be a fixed pixel height instead of a percentage in this case, or your other divs need to be set as percentages such that the total of your child divs is <= 100%.

Jeff B
I see. Thank you. I was under the impression, incorrectly, that "height: 100%" implies 100% of the *remaining* vertical area, but it is in fact 100% of total vertical parent area.
ikaushan
A: 

Set the height to 70% instead of 100% and see what happens.

Nicolas Viennot
Jeff B answer say it all.
Nicolas Viennot