Hide scroll bar, but while still being able to scroll

前端 未结 30 3389
悲哀的现实
悲哀的现实 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 04:49

    This is a divitis-esque solution which nontheless should work for all browsers...

    The markup is as follows and needs to be inside something with relative positioning (and its width should be set, for example 400 pixels):

    The CSS:

    .hide-scrollbar {
        overflow: hidden;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    .scrollbar {
        overflow-y: scroll;
        position: absolute;
        top: 0;
        left: 0;
        right: -50px;
        bottom: 0;
    }
    
    .scrollbar-inner {
        width: 400px;
    }
    

提交回复
热议问题