Kieran Senior
Kieran Senior

Reputation: 18230

Fixed Positioning With Scrolling

If, for example, I have a menu using fixed positioning but it's larger than the height of the current window, is there a way to allow this to scroll? The browser's default behaviour is to just hide it, and not let you access it.

div#sidebar {
    position:fixed;
    top:30px;
    left:0;
    bottom:4px;
    width:148px;
    background-color:#d7d7d7;
}

Here's a snippet of what I've currently got. Would it require some JavaScript or something along those lines?

EDIT: I'm not sure if this is actually possible to get correct. I want an element which is 30 pixels from the top of the document. I want to allow this to scroll using overflow:auto and height:100%. Either way I seem to do it, the scrollbar will be hidden, or a portion of the div will be hidden.

Upvotes: 23

Views: 57851

Answers (1)

Seb
Seb

Reputation: 25157

You'll need to set overflow:scroll (or overflow:auto) to that div, and set height to 100%.

Upvotes: 39

Related Questions