Ergebnis 1 bis 1 von 1

Thema: Change Scrollbar Color in CSS Websites

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Administrator Avatar von yilmaz

    Info

    Change Scrollbar Color in CSS Websites

    In this HTML and CSS tutorial, I will show you how to change and customize the side ScrollBar without using any JavaScript files. You will be able to create ScrollBar in the color and style you want. First we will have two files, index.html and style.css. Let's add basic HTML codes to index.html immediately.


    We linked the style.css to the index.html page with the link tag. Since our goal in this tutorial is to replace the ScrollBar, I need to add a paragraph that will reveal the ScrollBar. Let's do this right away with the P tag, by adding Dummy Text to it. This is how we add Dummy Texts. And when I save this file, you will see the ScrollBar on the right. Now let's move on to the style.css file to customize this ScrollBar. First of all, I added a body tag and gave the margins to make the page look nicer. I opened the lines. Now let's use the Justify code, where we justify the texts on both sides. So it will look more organized. Now that we have prepared the page in general, we can move on to customizing the ScrollBar. To customize the ScrollBar, we will use some codes on CSS and try these codes to see what they do. Primarily covering the scrollbar in general. We are adding the Webkit ScrollBar feature. We can apply different parameters to this property, let's start with the Background first. When we assign black color to the Background property, the scroll bar will be black as you can see here. The point where we hold the scrollbar will not be visible at the moment. Because right now we haven't determined it yet.


    I transfer the ScrollBar color by choosing a color from here. Let's add a color like this and we'll make the slider even darker. Now let's set its width. We will use the width value, if you want it to be thin, we can use 10 pixels or if we want it to be thicker, we can increase the number here. Let it stay at 14 events for now.

    HTML-Code:
    1. ::-webkit-scrollbar {
    2. background: #95a5a6;
    3. width: 14px;
    4. }
    5. ::-webkit-scrollbar-thumb {
    6. background: #2c3e50;
    7. }
    Demo 1:


    HTML-Code:
    1. /* width */
    2. ::-webkit-scrollbar {
    3. width: 20px;
    4. }
    5. /* Track */
    6. ::-webkit-scrollbar-track {
    7. box-shadow: inset 0 0 5px grey;
    8. border-radius: 10px;
    9. }
    10. /* Handle */
    11. ::-webkit-scrollbar-thumb {
    12. background: #2c3e50;
    13. border-radius: 10px;
    14. }
    15. /* Handle on hover */
    16. ::-webkit-scrollbar-thumb:hover {
    17. background: #b30000;
    18. }
    Demo 2

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 6 (Registrierte Benutzer: 0, Gäste: 6)

Benutzer, die dieses Thema gelesen haben: 0

Derzeit gibt es keine Benutzer zum Anzeigen.

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •