1

I have a website on which I want to have 3 independently scrollable <div> elements.

The html code is this:

<div class="sidebar">Content</div>
<div id="window">Some very long content</div>
<div class="sidebar">More content</div>

The associated css is this:

body {
    overflow: hidden;
}

#window {
    font-family: monospace;
    overflow: auto;
    width: 70%;
    float: left;
    height: 100%;
}

.sidebar {
    overflow: auto;
    width: 15%;
    float: left;
    height: 100%;
}

From what I saw via searching the internet, this is supposed to work. But I don't see any scrollbars at all.

Why?

How can i fix this issue?

1
  • 3
    overflow: auto only adds scrollbars if necessary. Is your content long enough to trigger them?
    – ajm
    Commented May 19, 2014 at 12:56

2 Answers 2

1

height: 100% as a percentage only affects the height of the element if that element's parent has an explicit height. The height of the body tag by default is the height of the content, not the full height of the window.

Try adding this:

html, body { height: 100%; }
2
  • Unfortunately this seems to not have any effect
    – Kilobyte
    Commented May 19, 2014 at 13:09
  • 1
    I just realized i had another sourrounding div which did not have the heigth: 100%; attribute. Adding it fixed the issue. Thanks for the help!
    – Kilobyte
    Commented May 19, 2014 at 13:17
0

Because of your height: 100%; your divs will just adjust to the height of the text. By changing your height to for example: 250px your code will work. Hope this helps. :)

1
  • The problem is that i want it to span full screen heigth. I cannot predict how high the window is
    – Kilobyte
    Commented May 19, 2014 at 13:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.