Improve the Quality of the Scrolling Experience with Custom CSS Scrollbars

1 year ago

3 min read

Posted by:

Focus

Subscribe to newsletter

By subscribing you agree to with our Privacy Policy.

Share

Hello guys! Have you ever thought about how to improve the appearance of the scrollbar on your website page? A good scrollbar will make the user experience not only smooth but also more aesthetic. In this post, I will discuss how to customize scrollbars using CSS.

The following is a CSS code snippet that you can use to customize the appearance of the scrollbar on screens that have a device width of at least 767px:

Light Mode:

@media only screen
and (min-device-width: 767px)
{
/* width */
::-webkit-scrollbar {
  width: 18px;
}

/* Track */
::-webkit-scrollbar-track {
  background: #181818;

}

/* Handle */
::-webkit-scrollbar-thumb {
  background: #888;
	border-radius: 9px;
box-shadow: inset 0 0 10px 10px #888;
    border: solid 4px #181818;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: #A1A1A1;
	box-shadow: inset 0 0 10px 10px #A1A1A1;
    border: solid 4px #181818;
}
}

Using the code above will help you:

  • Set the scrollbar width to 13px
  • Changed the background color of the scrollbar track to #F0F0F0
  • Change the appearance of the scrollbar handle with a white background, 9px radius, gray box-shadow, and a 3px border colored #F0F0F0
  • Adds a soft effect to the scrollbar handle when the user hovers over it with a colored background #e5e5e5, box-shadow #B1B1B1, and border #F0F0F0


Dark Mode

If your project required a dark color scroll bar, please use this one below:

@media only screen
and (min-device-width: 767px)
{
/* width */
::-webkit-scrollbar {
  width: 18px;
}

/* Track */
::-webkit-scrollbar-track {
  background: #181818;

}

/* Handle */
::-webkit-scrollbar-thumb {
  background: #888;
	border-radius: 9px;
box-shadow: inset 0 0 10px 10px #888;
    border: solid 4px #181818;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: #A1A1A1;
	box-shadow: inset 0 0 10px 10px #A1A1A1;
    border: solid 4px #181818;
}
}

Keep in mind that the code above only works on browsers that support the CSS ::-webkit-scrollbar syntax (such as Chrome, Safari, and Opera). For other browser support, you may need to look for another solution.

Hopefully this information is useful for those of you who are looking for ways to improve the appearance of your website. Good luck and always success on your web projects!

Read more

Woocommerce

< 1 min read

Disable Billing Address

Simplify checkout for virtual products or order via WhatsApp. Add this code in function.php. CODE PHP

Read more

PWA

4 min read

How to Publish an App with PWA for WP

Note: On PWA for WP, the icon logo and splash screen are swapped. Please test the .apk before publishing. Also,

Read more

PHP

< 1 min read

Maximize PHP Settings Manually on Plesk

Go to ‘File Manager’, edit .htaccess, and add this code after # END WordPress

Read more

Image

< 1 min read

Crop Image To Ratio

To crop image based on ratio, on Elementor’s Image Widget add this CSS: 16:9 Landscape CSS 9:16 Portrait CSS

Read more

See How It Works

Create better websites, faster.

Download the Entire Library

Adaptative, neutrally designed components.

Customer Service

Focus Website

Today, December 9

Hi, there 👋

How can I help you?

Start Chat with:

We use cookie to improve your experience on our site. By using our site you consent cookies.