Hide scroll bar, but while still being able to scroll

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

    On modern browsers you can use wheel event:

    // Content is the element you want to apply the wheel scroll effect to
    content.addEventListener('wheel', function(e) {
        const step = 100; // How many pixels to scroll
    
        if (e.deltaY > 0) // Scroll down
            content.scrollTop += step;
        else // Scroll up
            content.scrollTop -= step;
    });
    

提交回复
热议问题