Hide scroll bar, but while still being able to scroll

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

    Use

    function reloadScrollBars() {
        document.documentElement.style.overflow = 'auto';  // Firefox, Chrome
        document.body.scroll = "yes"; // Internet Explorer only
    }
    
    function unloadScrollBars() {
        document.documentElement.style.overflow = 'hidden';  // firefox, chrome
        document.body.scroll = "no"; // Internet Explorer only
    }
    

    Call these functions for any point you want to load or unload or reload the scrollbars. It is still scrollable in Chrome as I tested it in Chrome, but I am not sure of the other browsers.

提交回复
热议问题