<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dolen Ch. Deori</title>
    <description>The latest articles on DEV Community by Dolen Ch. Deori (@dolendeori).</description>
    <link>https://dev.to/dolendeori</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F728084%2F987ef5e2-2784-422a-9867-5f9cae9a4e4c.jpeg</url>
      <title>DEV Community: Dolen Ch. Deori</title>
      <link>https://dev.to/dolendeori</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dolendeori"/>
    <language>en</language>
    <item>
      <title>Customizing Scroll bar With Css.</title>
      <dc:creator>Dolen Ch. Deori</dc:creator>
      <pubDate>Mon, 18 Oct 2021 04:19:19 +0000</pubDate>
      <link>https://dev.to/dolendeori/customizing-scroll-bar-with-css-1k32</link>
      <guid>https://dev.to/dolendeori/customizing-scroll-bar-with-css-1k32</guid>
      <description>&lt;p&gt;Having a custom scroll bar gives a more personalize look and feel to your website.&lt;br&gt;
In this tutorial we will learn how we can customize scroll bar with CSS.&lt;/p&gt;
&lt;h4&gt;
  
  
  Make the HTML and CSS files
&lt;/h4&gt;

&lt;p&gt;Now first we have to do the small set up for our HTML and CSS files. Go ahead and make &lt;code&gt;index.html&lt;/code&gt; file and &lt;code&gt;style.css&lt;/code&gt; file that’s all we are gonna need today.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure you link the css file to your html file&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Basic HTML and CSS styling
&lt;/h3&gt;

&lt;p&gt;Now write the following HTML code in your &lt;code&gt;index.html&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
    &amp;lt;title&amp;gt;Scroll Bar&amp;lt;/title&amp;gt;

    &amp;lt;!-- CSS FILE LINK --&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;!-- LOREM IPSUM TEXT FOR DEMO --&amp;gt;
    &amp;lt;div class="main-page-body"&amp;gt;
      &amp;lt;h1&amp;gt;CUSTOM SCROLLBAR WITH CSS&amp;lt;/h1&amp;gt;
      &amp;lt;p class="demo-text"&amp;gt;
        &amp;lt;!-- Insert a Bunch of Demo text Here --&amp;gt;
      &amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code does nothing but use a bunch of text so that our scroll bar can visible.&lt;/p&gt;

&lt;p&gt;Now style the texts with some basic styling. write these CSS code in your &lt;code&gt;style.css&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* RESET DEFAULT STYLING */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* STYLING THE TEXT */
.main-page-body p.demo-text {
  font-family: sans-serif;
  margin: 3vw;

  /* Using the "vw" unit so the page zoom dosent effect our text 
  size and line height */

  font-size: 2vw;
  line-height: 3vw;
  text-align: justify;
}

.main-page-body h1 {
  font-family: sans-serif;
  font-size: 4vw;
  margin: 3vw;
  color: #ff34ee;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can follow this code or write your own styling as your wish.&lt;/p&gt;

&lt;h3&gt;
  
  
  Know about scrollbar.
&lt;/h3&gt;

&lt;p&gt;Before moving forward, have a look at different parts of a scroll bar it will help us to understand the CSS code.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7khpi0fsz6kk6jpqdh4e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7khpi0fsz6kk6jpqdh4e.png" alt="Scrollbar Diagram"&gt;&lt;/a&gt;&lt;br&gt;
These are the parts that we are going to style with our css.&lt;/p&gt;
&lt;h3&gt;
  
  
  Styling the scrollbar
&lt;/h3&gt;

&lt;p&gt;Now it’s time to style our scroll bar. To do that we are going to use 3 webkit properties of CSS this are  &lt;code&gt;::-webkit-scrollbar&lt;/code&gt; , &lt;code&gt;::-webkit-scrollbar-track&lt;/code&gt; , &lt;code&gt;::-webkit-scrollbar-thumb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now add this CSS code to your &lt;code&gt;style.css&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* STYLING SCROLLBAR */

::-webkit-scrollbar {
  width: 1vw; /* THIS WILL RESET THE DEFAULT SCORLLBAR STYLING */
}

/* TO STYLE THE SCROLLBAR TRACK */
::-webkit-scrollbar-track {
  background-color: #ffffff; /* THIS WILL SET THE COLOR OF THE SCROLLBAR TRACK */
}

/* TO STYLE THE SCROLLBAR THUMB */
::-webkit-scrollbar-thumb {
  background-color: #ff34ee;
  border: 0.3vw solid #ffffff;
  border-radius: 5vw;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CSS codes for customizing your scroll bar looks likes this.&lt;/p&gt;

&lt;p&gt;Now we are using &lt;code&gt;::-webkit-scrollbar&lt;/code&gt; to reset the default styling of the scrollbar. After we have defined our width in &lt;code&gt;::-webkit-scrollbar&lt;/code&gt; property, Then we have styled our scroll bar track with &lt;code&gt;::-webkit-scrollbar-track&lt;/code&gt; property. At last we styled our scroll bar thumb with &lt;code&gt;::-webkit-scrollbar-thumb&lt;/code&gt; property. And that’s it you can now play around these properties to create amazing looking custom scroll bars.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgn5dbu0onzrps155ybxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgn5dbu0onzrps155ybxp.png" alt="Demo Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: this &lt;code&gt;webkit&lt;/code&gt; property only going to work on webkit based browsers like (chrome , all IOS based browsers, opera etc.) know more about webkit &lt;a href="https://webkit.org/" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To know more about these css properties visit &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Scrollbars" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>css</category>
      <category>html</category>
    </item>
  </channel>
</rss>
