3

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,

1 Answer 1

6

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%.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.