DEV Community

ahoNerd
ahoNerd

Posted on • Originally published at ahonerd.com on

Hide Scrollbars using CSS but Keep Functionality

Cara untuk menyembunyikan scrollbar tapi konten tetap bisa di-scroll dengan menggunakan CSS.

Explanation

Untuk menyembunyikan scrollbar dengan CSS, sebetulnya kita dapat menggunakan:

.hidden-scrollbar {
  /* Hide vertical and horizontal scrollbars */
  overflow: hidden;
}
Enter fullscreen mode Exit fullscreen mode

atau

.hidden-scrollbar {
  /* Hide vertical scrollbars */
  overflow-y: hidden;
  /* Hide horizontal scrollbars */
  overflow-x: hidden;
}
Enter fullscreen mode Exit fullscreen mode

Apabila kita menggunakan metode di atas, meskipun betul dengan begitu scrollbar akan disembunyikan, akan tetapi konten juga akan menjadi tidak dapat di-scroll seperti yang diharapkan.

Hide Scrollbars But Keep its Function

/*
untuk browser berbasis webkit seperti
Chrome, Opera, Safari dan Edge versi baru
*/
.hidden-scrollbar::-webkit-scrollbar {
  display: none;
}

/* untuk Internet Explorer dan Edge versi lama and Firefox */
.hidden-scrollbar {
  /* IE dan Edge versi lama */
  -ms-overflow-style: none;
  /* Firefox */
  scrollbar-width: none;
}
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay