htmlcssscrollbarsidenav

CSS/DIV question - Scrollbar moves, but content does not


Context: Wordpress, custom page Situation: I open a sidepanel with more info when user clicks on a 'Read more' in the page.

Problem: The sidepanel appears with a scrollbar, but moving the scroll bar does nothing. That is, the content does not move.

Please see: https://www.staging11.primeinvestor.in/prime-etfs/

(Please click on the third 'Read more' link)

Appreciate the help!

thanks,

Srikanth

My CSS is:

   .sidenav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1;
    top: 0;
    right: 0;
    background-color: #fff7f4;
    overflow-x: hidden;
    overflow-y: scroll;
    transition: 0.5s;
    padding-top: 130px;
    padding-left: 10px;
    padding-right: 10px;
    color: #35080c;
    font-weight: 400;
  }

  .sidenav p {
    margin-right: 10px;
  }

  .sidenav a {
    padding: 8px 8px 8px 32px;
    text-decoration: none;
    font-size: 20px;
    color: #35080c;
    display: block;
    transition: 0.3s;
  }

  .sidenav a:hover {
    color: #dc4b00;
  }

  .sidenav .closebtn {
    position: absolute;
    top: 0;
    right: 20px;
    font-size: 14px;
    margin-left: 10px;
    padding-top: 100px;

  }

  @media screen and (max-height: 450px) {
    .sidenav {
        padding-top: 15px;
    }

    .sidenav a {
        font-size: 18px;
    }

    .sidenav .closebtn {
        padding-top: 10px;
        font-size: 16px
    }
  }

Solution

  • You should not use position: fixed; to make your element scrollable. fixed positions will make your element stick right where it is even if scrollbar is working. Instead, use

    .sidenav {
        ....
        position: relative; // change your code here
        z-index: 1;
        top: 0;
        right: 0;
        ....
      }