Hide scroll bar, but while still being able to scroll

前端 未结 30 4350
悲哀的现实
悲哀的现实 2020-11-21 04:22

I want to be able to scroll through the whole page, but without the scrollbar being shown.

In Google Chrome it\'s:

::-webkit-scrollbar {
    display:         


        
30条回答
  •  生来不讨喜
    2020-11-21 05:05

    I happen to try the above solutions in my project and for some reason I was not able to hide the scroll bar due to div positioning. Hence, I decided to hide the scroll bar by introducing a div that covers it superficially. Example below is for a horizontal scroll bar:

    My content that could overflow horizontally
     

    Corresponding CSS is as follows:

    #container{
       width: 100%;
       height: 100%;
       overflow: hidden;
       position: relative;
    }
    
    #content{
      width: 100%;
      height: 100%;
      overflow-x: scroll;
    }
    #scroll-cover{
      width: 100%;
      height: 20px;
      position: absolute;
      bottom: 0;
      background-color: #fff; /*change this to match color of page*/
    }
    

提交回复
热议问题