Two divs scrolling independently

后端 未结 2 534
借酒劲吻你
借酒劲吻你 2021-02-07 20:28


I need help to make these two

\'s (#side-nav and #content-wrapper) to scroll independently,

HTML:



        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 21:01

    Check this: http://codepen.io/anon/pen/xGyMjM

    You need to set height to content-wrapper, and also set the left, right & top.

    #side-nav {
      position: fixed;
      width: 250px;
      height:100vh;
      left: 0;
      right: 0;
      overflow-y: scroll;
      background-color: red;
      top: 60px;
    }
    
    #content-wrapper {
      margin: 60px 0 0 250px;
      padding: 0 30px;
      overflow-y: scroll;
      position: fixed;
      left: 0;
      top: 0;
      height:100vh;
      background-color: blue;
    }
    

提交回复
热议问题