N30V3N0M's profile picture

Published by

published
updated

Category: Web, HTML, Tech

CSS Coding for your scrollbar!

Just a heads up, I've only tested this with Chrome so Idk if it will work with other browsers.  Using CSS Tricks (click on it for more details), I manage to put together some CSS coding to customize your scrollbar!  All you gotta do is change the hex code to the color you want, which looks like this "#111111" in the coding.  The only bummer is that when you use the code, the scrollbar direction arrows do disappear.  I kinda did a workaround by using images of arrows and placed them over the scrollbar buttons as URL links; I've included some base ones for people to use.  If you wanna change the colors of the arrows, you're going to have to open the images up with Photoshop, GIMP, or other similar programs, change the color for all eight arrows, upload them on the net, grab the URL, and replace each URL (I know, sounds complicated).  Anyways, I will include the code below.  IMPORTANT:  Be sure to put this code after your profile coding so you don't jack up your existing code!!!  Note:  I am no coding expert but wanted to share with you guys what I've to manage to cook up. :)  Another note:  Also, if you don't care about having direction arrows on your scroll bar, just copy/paste the first half of the code, before " /* Scrollbar Buttons */ ".


Code:

<style>
/*Customizes scroll bar*/
/* width */
::-webkit-scrollbar
{
  width: 15px;
}

/*Customizes color of the direction buttons*/  
::-webkit-scrollbar-button:start {
    background-color: #f1f1f1;
}

::-webkit-scrollbar-button:end {
    background-color: #f1f1f1;
}

/*Customizes color of Handle */
::-webkit-scrollbar-thumb
{
  background-color: #c1c1c1;
  border-radius: 0px;
}

/*Customizes color of Handle hover*/
::-webkit-scrollbar-thumb:hover {
  background: #9c9c9c;
}  
  
/*Customizes color of Track */
::-webkit-scrollbar-track
{
  -webkit-box-shadow: inset 0 0 6px #f1f1f1;
  background-color: #f1f1f1;
  border-radius: 0px;
}
</style>



<style>
/* Scrollbar Buttons */
/*Width*/  
::-webkit-scrollbar-button
{
  height: 16px;
  width: 16px;
}

/* Up */
::-webkit-scrollbar-button:vertical:decrement
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/0yt2dVc/Arrow-Up.png");
}

/*Up Hover*/  
::-webkit-scrollbar-button:vertical:decrement:hover
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/Fn2qWmj/Arrow-Up-hover.png");
}


/* Down */
::-webkit-scrollbar-button:vertical:increment
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/rGMFVKm/Arrow-Down.png");
}

/*Down Hover*/  
::-webkit-scrollbar-button:vertical:increment:hover
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/PYWv05Q/Arrow-Down-hover.png");
}


/* Left */
::-webkit-scrollbar-button:horizontal:decrement
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/brJnjD4/Arrow-Left.png");
}

/*Left Hover*/  
::-webkit-scrollbar-button:horizontal:decrement:hover
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/0rQhWN5/Arrow-Left-hover.png");
}


/* Right */
::-webkit-scrollbar-button:horizontal:increment
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/4dyTzJt/Right.png");
}

/*Right Hover*/
::-webkit-scrollbar-button:horizontal:increment:hover
{
    height: 16px;
    width: 16px;
    background-position: center center;
    background-image: url("https://i.ibb.co/qrRZ8CR/Right-Hover.png");
}
</style>


20 Kudos

Comments

Displaying 1 of 1 comments ( View all | Add Comment )

ruffiØ

ruffiØ's profile picture

oh yea scrollbars in blogs. ;) haha


Report Comment



Scrollbar code with a scrollbar table! Mind blown!

by N30V3N0M; ; Report