How can I apply custom CSS code to style the scrollbar on my Webflow site? I've tried placing the code in the Settings section under custom code and in the Head Code, and applying the class to either the body or the "filter_options" div in the project, but I'm not seeing any changes. Any suggestions?

TL;DR
  • Ensure custom scrollbar styles are supported in Webkit-based browsers (Chrome, Safari).
  • Add custom CSS for the scrollbar in Webflow's Project Settings under Custom Code in the Before </body> section.
  • Apply the targeted class to the desired element in Webflow Designer.
  • Publish the site and test in a supported browser to confirm changes.

Applying custom CSS to a scrollbar in Webflow can be a bit tricky due to specific browser support and the methods to designate custom styles. Here's how you can effectively apply custom CSS to your scrollbar.

1. Verify Browser Support

  • Custom scrollbar styles are supported in Webkit-based browsers (like Chrome and Safari) using the ::-webkit-scrollbar pseudo-element.
  • Ensure your audience primarily uses supported browsers for the changes to appear as expected.

2. Add Custom Code in Site Settings

  • Navigate to your Webflow Project Settings.
  • Go to the Custom Code section.
  • Add your CSS code for the scrollbar styling within the <style> tag in the Before </body> tag section. Example:

  ```css

  <style>

    / Custom Scrollbar Styles /

    .your-scrollbar-class::-webkit-scrollbar {

      width: 12px;

    }

    .your-scrollbar-class::-webkit-scrollbar-track {

      background: #f1f1f1;

    }

    .your-scrollbar-class::-webkit-scrollbar-thumb {

      background: #888;

    }

    .your-scrollbar-class::-webkit-scrollbar-thumb:hover {

      background: #555;

    }

  </style>

  ```

3. Apply Class to Target Element

  • Return to the Webflow Designer.
  • Give the element you want to style (body, div, etc.) a specific class (e.g., your-scrollbar-class).
  • Ensure the class name in your CSS matches the class name you’ve applied in Webflow.

4. Publish and Test

  • Publish your site to ensure all changes are applied.
  • Test the scrollbar appearance in a Webkit-based browser to confirm the styling appears as desired.

Summary

To apply custom styles to a scrollbar, ensure you're targeting the correct elements and using Webkit-specific pseudo-elements. Always test after publishing to check for effective changes.

Rate this answer

Other Webflow Questions