Languages
[Edit]
EN

CSS - disable scroll bar

4 points
Created by:
Paris-Bateman
504

In this short article, we would like to show how to disable a scrollbar using pure CSS.

Disabled scrollbar with pure CSS.
Disabled scrollbar with pure CSS.

Quick solution:

.my-element {
    overflow: hidden;  /* disables scrollbar */
}

Note: go to this article to see the pure JavaScript version.

 

Practical example

This section shows how to disable both scrollbars using overflow: hidden;.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>
    
    .my-element {
    	border: 1px solid red;
      	height: 100px;
      	overflow: hidden;  /*  <------- required to disable scrollbar  */
    }
    
  </style>
</head>
<body>
  <div class="my-element">
    Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br />
    Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br />
    Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br />
    Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br />
    Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br />
    Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br /> Sime text...<br />
  </div>
  </script>
</body>
</html>

See also

  1. JavaScript - stop page scroll with e.preventDefault() 

Alternative titles

  1. CSS - remove scrollbar
  2. CSS - hide scrollbar
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join