Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webkit css scrollbar styling

Is there any way of getting rid of the scroll track entirely? Or making it overlay the content rather than pushing it aside? Like iOS/Lion scrollbars?

The following gets pretty close, but even though the track is transparent, the content of the scrollable region is pushed over and the page background shows through.

::-webkit-scrollbar {  
    width:8px;
    height:8px;
    -webkit-border-radius: 4px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-track-piece {
    background-color:transparent;
}

::-webkit-scrollbar-thumb {  
    background-color: rgba(053, 057, 071, 0.3);
    width: 6px;
    height: 6px;
    -webkit-border-radius:4px;
}
like image 522
nicholas Avatar asked Aug 28 '11 23:08

nicholas


People also ask

How do I change the scrollbar on Webkit?

Scrollbar Selectors For webkit browsers, you can use the following pseudo elements to customize the browser's scrollbar: ::-webkit-scrollbar the scrollbar. ::-webkit-scrollbar-button the buttons on the scrollbar (arrows pointing upwards and downwards). ::-webkit-scrollbar-thumb the draggable scrolling handle.

Can you style the scrollbar CSS?

As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers. In this tutorial, you will learn how to use CSS to customize scrollbars to support modern browsers.

Can I use webkit scrollbar?

Note: ::-webkit-scrollbar is only available in Blink- and WebKit-based browsers (e.g., Chrome, Edge, Opera, Safari, all browsers on iOS, and others). A standardized method of styling scrollbars is available with scrollbar-color and scrollbar-width .

What is Webkit scrollbar in CSS?

::-webkit-scrollbar is a pseudo-element in CSS employed to modify the look of a browser's scrollbar. Before we start with how it works and how can it be implemented, we need to know some facts about the element. Browsers like Chrome, Safari and Opera support this standard. Browsers like firefox don't support this.


1 Answers

Hmm, I thought I answered this one previously, maybe not:

  • Hide the overflow on the body
  • wrap the entire content of the site or whatever you're scrolling with a div,
  • Incude css properties for the div (overflow:scroll or overflow-y:scroll).

Now you can set the track css to any opacity using rgba(0,0,0,0.3) because the scroll is not part of the body.

Another tip for customizing firefox scroll bar if you want to experiment is to:

  • Do the overflow thing and to overlay the scrollbar (via z-index) with a transparent div of whatever color you like,
  • Position the div over the entire scroll section (probably something like position:absolute; right:0; if you're using the scroll for the entire window)
  • Use pointer-events: none; on the divs css to make it semi-transparent.

It will give the firefox scroll a little color/ texture. (May be ideal to force the scroll to the right for comparability)

I've not tried it yet but it's do-able

like image 129
frontsideup Avatar answered Oct 24 '22 11:10

frontsideup