Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Child of position: fixed; won't scroll

Tags:

css

I have a sidebar with position: fixed. Inside this sidebar, I have a .list where I want to use overflow: scroll. However, it is not working as I want it to.

HTML

<div id="side">

    Stuff

    <div id="list">
        <div class="item">An item</div>
    </div>

</div>

CSS

#side {
    width: 20%;
    height: 100%;
    background-color: red;
    position: fixed;
}

#list {
    width: 100%;
    background-color: yellow;

    overflow: scroll;
}

.item {
    padding: 10px;
}

JSFiddle of the problem: http://jsfiddle.net/wGE9W/ (the yellow list won't scroll)

like image 226
Patrick Reck Avatar asked Oct 17 '25 17:10

Patrick Reck


1 Answers

Add a height:

#list {
    width: 100%;
    height: 500px;
    background-color: yellow;
    overflow: scroll;
}

Updated fiddle

The height needs to be 100% – Patrick Reck 46 secs ago

Then why can't you just change it to that?

#list {
    width: 100%;
    height: 100%;
    background-color: yellow;
    overflow: scroll;
}

Fiddle

like image 191
tckmn Avatar answered Oct 20 '25 09:10

tckmn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!