Skip to content

CSS Custom Scrollbar Not Showing Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about CSS Custom Scrollbar Not Showing Fix. We cover key concepts, practical examples, and best practices.

The Problem

You style the scrollbar with ::-webkit-scrollbar but nothing changes. The scrollbar looks default, or it disappears entirely. Custom scrollbar styling uses vendor-prefixed pseudo-elements that differ across browsers.

Quick Fix

Step 1: Use the correct vendor prefix for Chrome, Safari, Edge

/* Wrong — missing pseudo-elements */
.custom-scroll {
    scrollbar-color: red blue;
}

/* Right — full webkit scrollbar styling */
.custom-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.custom-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}
.custom-scroll::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: #555;
}

Expected output: A custom gray scrollbar with rounded thumb appears in Chrome and Edge.

Step 2: Add Firefox support with scrollbar-width and scrollbar-color

.custom-scroll {
    /* Wrong — only webkit styling, Firefox ignores */
    /* Right — Firefox properties */
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

Expected output: Firefox shows a thin scrollbar with matching colors.

Step 3: Ensure overflow is set to auto or scroll

Custom scrollbar styles only apply when the element scrolls:

/* Wrong — overflow hidden hides scrollbar */
.custom-scroll {
    overflow: hidden;
}

/* Right */
.custom-scroll {
    overflow: auto;
    max-height: 400px;
}

Expected output: The scrollbar appears when content overflows.

Step 4: Combine webkit and Firefox styles for cross-browser support

.custom-scroll {
    max-height: 400px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}
.custom-scroll::-webkit-scrollbar {
    width: 8px;
}
.custom-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.custom-scroll::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

Expected output: The scrollbar is customised across Chrome, Firefox, Safari, and Edge.

Step 5: Check for browser compatibility

Only Chrome, Edge, and Safari support ::-webkit-scrollbar. Firefox supports scrollbar-width and scrollbar-color. There is no cross-browser solution for Internet Explorer. Test custom scrollbars on actual devices before shipping.

Prevention

  • Always test scrollbar styles in Chrome, Firefox, and Safari separately
  • Use scrollbar-width: thin for Firefox as a baseline
  • Do not hide scrollbars if content is scrollable — it harms accessibility
  • Add custom scrollbar styles last in your stylesheet to avoid accidental overrides

Common Mistakes with scrollbar custom

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world CSS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does my custom scrollbar work in Chrome but not Firefox?

Firefox does not support ::-webkit-scrollbar. Use scrollbar-width and scrollbar-color for Firefox. These are standard CSS properties that Firefox has supported since version 64.

Can I style the scrollbar on the entire page?

Yes. Use ::-webkit-scrollbar without a class prefix for the global scrollbar: html::-webkit-scrollbar { width: 10px; }. For Firefox, apply styles to html or body.

Will custom scrollbar styling affect performance?

Minimally. Scrollbar styling does not trigger layout recalculations. However, avoid complex box-shadow or background-image on scrollbar elements to keep scrolling smooth.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro