Languages
[Edit]
EN

CSS - disable scroll bar

4 points
Created by:
Paris-Bateman
254

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() 
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