How to hide the scroll bar if not needed with CSS?

Spread the love

Sometimes, we want to hide the scroll bar if not needed with CSS.

In this article, we’ll look at how to hide the scroll bar if not needed with CSS.

How to hide the scroll bar if not needed with CSS?

To hide the scroll bar if not needed with CSS, we can set the overflow properties to auto.

For instance, we write

.content {
  overflow: auto;
}
.content {
  overflow-y: auto;
}
.content {
  overflow-x: auto;
}

to set overflow to auto to hide the vertical and horizontal scroll bars if there’s no overflow content.

We set overflow-y to auto to hide the vertical scroll bar if there’s no overflow content.

And we set overflow-x to auto to hide the horizontal scroll bar if there’s no overflow content.

Conclusion

To hide the scroll bar if not needed with CSS, we can set the overflow properties to auto.

Leave a Reply

Your email address will not be published. Required fields are marked *