Skip to content

Instantly share code, notes, and snippets.

@umidjons
Last active May 2, 2022 12:30
Show Gist options
  • Select an option

  • Save umidjons/9927376 to your computer and use it in GitHub Desktop.

Select an option

Save umidjons/9927376 to your computer and use it in GitHub Desktop.
Hide browser's scroll bar, but be able to scroll.

Hide browser's scrollbars, but be able to scroll

My HTML structure was as following (I've used twitter bootstrap):

<body>
  <div class="container">
  	<!-- long content -->
  </div>
</body>

To hide scrollbars I've used this CSS code:

body{
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.container{
	overflow: auto;
}

Original code was as this in jsFiddle:

<div id="container1">
  <div id="container2">
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    hello<br/>I<br/>am<br/>here<br/>
    good<br/>bye.
  </div>
<div>
#container1{
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#container2{
    width: 100%;
    height: 99%;
    overflow: auto;
}

html, body{
    height: 100%;
    overflow: hidden;
}
@nixpulvis

Copy link
Copy Markdown

This doesn't seem to work on either Firefox or Chromium on my Linux laptop.

@AnishMandal939

Copy link
Copy Markdown

/*for chrome*/ ::-webkit-scrollbar { display: none; }
scrollbar-width: none; /* Firefox */ -ms-overflow-style: none; /* IE 10+ */

this is the trick that can save life from scrolling behavior width with scroll behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment