Scroll part of content in fixed position container

后端 未结 5 637
逝去的感伤
逝去的感伤 2020-12-08 00:27

I have a position: fixed div in a layout, as a sidebar. I\'ve been asked to have part of it\'s content stay fixed to the top of it (internally), and the rest to

5条回答
  •  不知归路
    2020-12-08 00:43

    I changed scrollable div to be with absolute position, and everything works for me

    div.sidebar {
        overflow: hidden;
        background-color: green;
        padding: 5px;
        position: fixed;
        right: 20px;
        width: 40%;
        top: 30px;
        padding: 20px;
        bottom: 30%;
    }
    div#fixed {
        background: #76a7dc;
        color: #fff;
        height: 30px;
    }
    
    div#scrollable {
        overflow-y: scroll;
        background: lightblue;
    
        position: absolute;
        top:55px; 
        left:20px;
        right:20px;
        bottom:10px;
    }
    

    DEMO with two scrollable divs

提交回复
热议问题