Blog Layout

Website Scroll Bars

Aj • November 3, 2024

In This Article:

Custom Scrollbar Styling Tutorial for Duda Websites

Customizing the scrollbar adds a unique touch to your website's design. With the CSS provided, you can change         the scrollbar’s color, size, and even its hover effects. By following this guide, you’ll learn how to apply         this code to your Duda website and personalize it to match your brand.


Step 1: Understanding the CSS Code

Below is the code snippet we’ll be using. Each part of the code is explained in detail to help you make adjustments:

  /* WEBSITE SCROLL BAR CSS */

::-webkit-scrollbar {

  width: 15px;

}

::-webkit-scrollbar-track {

  box-shadow: inset 0 0 10px #eeeeee;

  border-radius: 5px;

}

::-webkit-scrollbar-thumb {

  background: #23a0a3;

  border-radius: 5px;

}

::-webkit-scrollbar-thumb:hover {

background: #1b7d7e;

}  


Explanation of Each Selector:

  •   ::-webkit-scrollbar : This targets the scrollbar itself and allows us to set its width. Here, we set the  width   to  15px   . You can adjust this to make the scrollbar narrower or wider, depending on your design preference.
  •   ::-webkit-scrollbar-track : This defines the track of the scrollbar—the area in which the scrollbar thumb moves. We use the  box-shadow   property to add a subtle inner shadow effect (  inset 0 0 10px #eeeeee   ), giving it a more defined, styled appearance. The  border-radius   of  5px   rounds the corners of the scrollbar track. Adjusting the radius here will make it more or less rounded.
  •   ::-webkit-scrollbar-thumb : This targets the thumb(the part of the scrollbar you drag to scroll). We set the  background   color to  #23a0a3   (a teal color in this case). The  border-radius   of  5px   rounds the corners of the thumb, making it more visually appealing and matching the style of the track.
  •   ::-webkit-scrollbar-thumb:hover : This modifies the thumb’s appearance when hovered over. We change the  background   color to a darker shade,  #1b7d7e   , to give users a visual cue when they hover.


Note: These properties apply to WebKit browsers like Chrome and Safari. Firefox and Internet Explorer require different properties, which aren’t supported in Duda at this time.


Step 2: Adding the Code to Your Duda Site

  1. Navigate to Site CSS:
  • In Duda’s editor, go to Dev Mode > site.css
  • Alternatively, if you want this to apply only to a specific page, you can use the Page CSS section for that page.
  1. Paste the Code: Copy the entire CSS code above and paste it into the CSS area.
  2. Save and Preview: Save the changes and preview your site to see the custom scrollbar styling in action.


Step 3: Customizing the Scrollbar

The following are some adjustments you can make to personalize the scrollbar further:

  • Scrollbar Width(  ::-webkit-scrollbar   ):
  • Adjust  width: 15px;   to make the scrollbar thinner or thicker. For example, setting it to  10px   will create a slimmer scrollbar.
  • Track Shadow Color and Radius(  ::-webkit-scrollbar-track   ):
  • Modify  box-shadow: inset 0 0 10px #eeeeee;   to change the shadow’s color and strength.
  • Change  #eeeeee   to any color that matches your site’s theme.
  • Adjust  border-radius: 5px;   to control the roundness. A smaller number (e.g.,  2px   ) makes it less rounded, while a larger number (e.g.,  10px   ) makes it more rounded.
  • Thumb Color and Radius(  ::-webkit-scrollbar-thumb   ):
  • Change  background: #23a0a3;   to any color that aligns with your brand.
  • Adjust  border-radius   similarly to control how rounded the thumb looks.
  • Hover Effect(  ::-webkit-scrollbar-thumb:hover   ):
  • The hover effect color (  #1b7d7e   ) provides visual feedback to users. Feel free to change this color to create contrast with the regular thumb color.


Example Customization

Let’s say you want a thinner scrollbar with a dark gray track and a blue thumb that turns light blue on hover.         

Here’s how that code might look:

::-webkit-scrollbar {

  width: 8px;

}


::-webkit-scrollbar-track {

  box-shadow: inset 0 0 5px #444444;

  border-radius: 2px;

}


::-webkit-scrollbar-thumb {

  background: #007bff;

  border-radius: 2px;

}


::-webkit-scrollbar-thumb:hover {

  background: #66b2ff;

}  


Step 4: Preview and Test Across Devices

After customizing the scrollbar, make sure to:

  • Preview the site to ensure the scrollbar looks and functions as expected.
  • Test on mobile and desktop to ensure the design feels right on different devices, even though custom scrollbars are primarily desktop features.


That’s it! With these steps, you now have a customized scrollbar that matches your Duda site’s design and enhances user experience. Enjoy experimenting with different styles and colors to find the perfect fit for your website!

A landing page for a website with a hover effect made easy.
By Aj Pfeil December 10, 2024
The Hover Float Effect is a versatile tool to enhance your web design. It’s subtle yet impactful, adding a layer of interactivity that keeps users engaged. With just a few lines of CSS, you can elevate the look and feel of your site, making it more dynamic and modern.
A close up of a laptop with a website on the screen
By Aj Pfeil December 7, 2024
A flashing tab title is a fun and effective way to grab your visitors’ attention when they navigate away from your site. By alternating between two messages in the browser tab, you can encourage users to return, highlight special offers, or just add a creative flair to your website.
A laptop is open to a page that says the blog topic
By Aj Pfeil December 6, 2024
Learn how to make your Duda Website stand out in the crowd with a Dynamic Scrolling Header. This header appears while scrolling up, and slides up off the canvas when scrolling down.
By Aj Pfeil December 4, 2024
Adding a Table of Content to your Duda Websites A Table of Contents (TOC) is a fantastic addition to any webpage, especially for blogs or long-form content. It enhances the user experience by providing quick navigation links to different sections on a page, improving readability and engagement. In this guide, I’ll show you how to implement a fully functional Table of Contents on your Duda website using a simple JavaScript snippet.
More Posts
Share by: