In this blog, we use the following controls to customize the browser’s scrollbar and then copy the CSS to use in your own websites!
Note:- I recommend trying different browsers to see how your scrollbar will be styled elsewhere.
Custom Scrollbar Generator Live Example
See the Pen Create Custom Scrollbar Generator by khushal (@mr__khushal) on CodePen.
There are several steps to create a Custom Scrollbar Generator. Which are shown below
Step1:- Create index.html File.
Custom Scrollbar Generator
Custom Scrollbar Generator
OUTPUT
COPY THIS CODE
/* ===== Scrollbar CSS ===== */
/* Firefox */
* {
scrollbar-width: thin;
scrollbar-color: blue orange;
}
/* Chrome, Edge, and Safari */
*::-webkit-scrollbar {
width: 12px;
}
*::-webkit-scrollbar-track {
background: orange;
}
*::-webkit-scrollbar-thumb {
background-color: blue;
border-radius: 20px;
border: 3px solid orange;
}
Debugger
Step2:- Create style.css File.
/* ===== App Styling ===== */
.info, .copy, input[type=color] {
cursor: pointer;
}
.mainhead h1{
text-align: center;
text-transform: uppercase;
text-shadow:2px 2px 5px rgba(0, 0, 0, 0.7);
}
.khushaloutput{
text-align: center;
background-color: #f5f5f5;
padding: 5px;
border-radius: 5px;
}
.info {
font-size: 1.5em;
padding: 0;
width: 40px;
height: 40px;
border-radius: 100%;
border: 4px solid #C8C6D2;
color: #C8C6D2;
background-color: inherit;
transition: all 500ms;
}
.info:hover {
color: #131313;
background-color: #C8C6D2;
font-weight: bold;
}
.appContainer {
align-items: center;
justify-content: flex-start;
height: inherit;
width: inherit;
padding: 0 40px;
}
.app {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 0;
margin: 0;
}
.scrollbarControls {
border: 1px solid #000;
border-radius: 5px;
padding: 0px;
background-color: #606060;
width: 35%;
color: #000;
}
.scrollbarControls>ul {
list-style: outside none none;
margin: 0;
padding: 0;
}
.scrollbarControls>h2 {
text-align: center;
text-transform: uppercase;
}
.copySection {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.copy {
background-color: gray;
font-size: 2em;
border-radius: 5px;
border: none;
padding: 10px;
transition: all 500ms;
}
.copy:hover {
color: white;
background-color: #BF9ACA;
}
.scrollbarControls label {
font-size: 1em;
text-align: right;
display: block;
width: 100%;
}
.scrollbarControls>ul>li {
border-bottom: 1px solid #000;
display:flex;
align-items: center;
justify-content: center;
}
.scrollbarControls>ul>li:first-child {
border-top: 2px solid #C8C6D2;
}
.scrollbarControls>ul>li:last-child {
border-bottom: none;
}
.scrollbarControls>ul>li>div {
width: 50%;
height: fit-content;
display: flex;
margin: 0;
padding: 12px;
}
.scrollbarControls>ul>li>div:last-child {
font-size: 0.8em;
align-items: center;
justify-content: left;
}
.scrollbarControls>ul>li>div:first-child {
align-items: center;
justify-content: right;
font-weight: bold;
}
input {
height: 30px;
width: 70px;
}
select {
height: 30px;
width: 70px;
}
input[type=color] {
border: none;
margin: 0;
padding: 0;
}
.scrollbarContainer {
overflow: scroll;
width: 200px;
height: 400px;
background-color:#f5f5f5;
padding: 40px;
}
.code {
padding: 5px;
background-color: #f5f5f5;
font-family: 'Source Code Pro';
color: #000;
font-size: 1.2em;
height: fit-content;
}