by Sai gowtham

How to hide the Scroll Bars using CSS

In this tutorial, we are going to learn about how to hide scroll bars (horizontally, vertically) in a webpage using the CSS.

Hiding the scroll bars

To hide the scroll bars both horizontally and vertically, we need to add an overflow: hidden to the parent element.

body{
  overflow: hidden;
}

Hiding the scroll bar Horizontally

To hide the horizontal scroll bar, we can use the overflow-x: hidden property.

body{
  overflow-x: hidden;
}

Hiding the scroll bar Vertically

To hide the vertical scroll bar, we can use the overflow-y: hidden property.

body{
  overflow-y: hidden;
}

Note: By adding an overflow: hidden it also disables the scrolling functionality, so we can’t able to scroll inside the webpage.

If you want to hide the scroll bar but you still be able to scroll inside the webpage, use the following CSS code.

.container{
   width: 200px;
   height: 400px;
   overflow-y: scroll;
}

.container::-webkit-scrollbar {
    display: none;  /* Safari and Chrome browsers */
}

.container {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none;  /* mozilla */
}

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course