Create custom scrollbars using CSS

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 286

  • @KevinPowell
    @KevinPowell  3 роки тому +43

    You can do more than I did here, including styling the up and down arrow buttons, the empty spaces on the top and bottom, and more! developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar

    • @Stoney_Eagle
      @Stoney_Eagle 3 роки тому +1

      Me: Opens Mozilla link in Firefox...
      Also me: Remembers ::webkit-*....

    • @risingson7681
      @risingson7681 3 роки тому

      Thank you for this. By now i never got it running on ff.

    • @wittywolk
      @wittywolk 2 роки тому

      We can't force this scrollbar to stay visible on mobile (ios or firefox on android) without using custom JS scrollbar right? I mean we can somehow trick that website is going 1px down and up all the time but it can cause problems. What do you think?

    • @Creative.K
      @Creative.K 2 роки тому

      Hi, @Kevin Powell. How do we get the hsl to have transparency?

  • @zachjensz
    @zachjensz 3 роки тому +300

    This really raises the bar for scrolling

    • @thobbs102670
      @thobbs102670 3 роки тому

      ua-cam.com/video/oShTJ90fC34/v-deo.html

    • @a-fletcher
      @a-fletcher 3 роки тому +15

      Well that's enough dad jokes for this morning 😆

    • @MarjoForcado
      @MarjoForcado 3 роки тому +3

      Ahhh humor 💀

    • @chomo54andbabyaisha97
      @chomo54andbabyaisha97 3 роки тому +3

      1998: Microsoft: Style your own scoll bars!
      2001: N&N Usability test: Custom scroll bars are bad for usability
      2021: W3C: Style your own scroll bars!

    • @bradhaupt1261
      @bradhaupt1261 3 роки тому +3

      Thank you for your contribution to humanity

  • @KiwisCode
    @KiwisCode 8 місяців тому +4

    While working on my portfolio project around 1 AM, I stumbled upon this video on how to beautify my scrollbar, and it's amazing! I'm really happy that you paid attention to these kinds of details. It was truly helpful and came just in time for me.

  • @Melksh1
    @Melksh1 3 роки тому +90

    I love how you actually demonstrate multiple options instead of just a plain tutorial.

    • @Gregorius421
      @Gregorius421 3 роки тому +5

      @Ahmad Bilal Yes, demonstrating the different possibilities is what hooked me to Kevin's videos. There's always something new I haven't thought of or knew about.

    • @Melksh1
      @Melksh1 3 роки тому +3

      @@Gregorius421 yep and it is a pretty unique style. I don't find many people doing this. I get to learn so much due to this. 🙌

  • @_ap__
    @_ap__ 3 роки тому +74

    I love Kevin's professionalism and premium style tutorials.

  • @MarcHoekstra
    @MarcHoekstra 3 роки тому +12

    You can use a transparent border in combination with "background-clip: content-box;" to move the scrollbar away from the side. In combination with "overflow: overlay;" on your html element this looks great, even if your page background isn't a static color!

    • @gomitchell
      @gomitchell 3 роки тому +6

      Any chance you have a codepen example?

  • @AttackHelicopter64
    @AttackHelicopter64 3 роки тому +3

    5:55 you can also have transparent border for thumb combined with background-clip: padding-box
    so you don't have to care about track color, if you just want to have "padding" for thumb

    • @AttackHelicopter64
      @AttackHelicopter64 3 роки тому +1

      + having :hover style, that removes border, so thumb grows when you hover over it

  • @jonmayer
    @jonmayer 2 роки тому +4

    5:19 right there, if you freeze you can see it. You CAN do a margin-inline on the scrollbar-track. It just only affects the horizontal scrollbars and not the vertical ones.

  • @domenicpolsoni8370
    @domenicpolsoni8370 3 роки тому

    I'm a simple man. I see a new video by Kevin, I watch and upvote.

  • @candym5280
    @candym5280 3 роки тому +1

    CSS never ceases to amaze me

  • @Gregorius421
    @Gregorius421 3 роки тому +1

    6:00 neat trick for transparent thumb border, needed if the track's background is a gradient or image:
    border: .25em solid transparent;
    background-clip: padding-box;

  • @graaam101
    @graaam101 3 роки тому +74

    6:36 "vertical-scroll" - affects the bit that scrolls horizontally 🤣 Pretty sure that is right out of my playbook of goofs!

    • @Dexter101x
      @Dexter101x 3 роки тому +4

      I thought I had misheard it, but yeah people do make mistakes

    • @keithf5236
      @keithf5236 3 роки тому +2

      so is the horizontal scroll actually referred to as vertical bc when you put vertical-scroll, it only affected the horizontal?

    • @conceptrat
      @conceptrat 3 роки тому +4

      @@keithf5236 Kevin has defined a class of vertical-scroll for specific divs/blocks of content that will be scrollable but the overflow attribute means that the one shown is actually only presenting a horizontally scrollable area. Hence the confusion.

  • @adityasagar9078
    @adityasagar9078 2 роки тому +1

    So easy to understand and so professional,you made my website look good

  • @tayyabnoor7471
    @tayyabnoor7471 3 роки тому

    Every front end developer should watch this video

  • @sharakpl
    @sharakpl 3 роки тому +1

    10:58 sometimes you want a block or even whole page scrolled but without the feeling of page being scrolled. That's where hiding (not disabling) scrollbars comes in handy. Thanks for another great video! I've just been looking for a scrollbar customization in new themes, but couldn't find good enough cross-browser way.

    • @KevinPowell
      @KevinPowell  3 роки тому

      Yeah, good point I should have thought of that :)

  • @jdlowen
    @jdlowen 2 роки тому +1

    CSS has evolved so much... what is your recommendation to learn the essential basics and the latest useful tricks. PS: of all the UA-camrs, I find you the most useful. Big thanks and keep it the great content. The fact that your screenshot show the final product and you describe what will be accomplish is what attracts me the most to your videos..

  • @r3pwn-dev
    @r3pwn-dev 3 роки тому +1

    Fun fact: in addition to :hover, you can also use :active on the thumb to style it differently (make it even darker) when the user's mouse button is pressed

  • @carolmckay5152
    @carolmckay5152 3 роки тому

    Thankyou for revisiting this topic but with MORE, I decided to style the chrome scrollbar to look like the firefox scrollbar which looks heaps better in my arrogant opinion. ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-button { height: 0; } ::-webkit-scrollbar-thumb { border-radius: 100vw; border: 3px solid; }

  • @juditturcsanyi6640
    @juditturcsanyi6640 3 роки тому +3

    Great video (as always)! The Firefox part is exactly what I needed today 🙏

  • @ranjoyguhathakurata5650
    @ranjoyguhathakurata5650 3 роки тому

    hey Kevin I love you. You dont know how good you are.Superb teacher. So much skill in css.Truely CSS king.Learned a lot from your videos and keep learning.

  • @yTheuszss
    @yTheuszss 6 місяців тому

    Hi man, you saved me from a mess I was in for hours, thank you

  • @MichaelHitzelberger
    @MichaelHitzelberger 3 роки тому +23

    Nice video, thanks!
    What got me confused a bit: Your 'vertical' scroll is actually a horizontal one. 😕

    • @KevinPowell
      @KevinPowell  3 роки тому +13

      🤦‍♂️

    • @The14Some1
      @The14Some1 10 місяців тому +1

      @@KevinPowell still not got used to this? :)

  • @vin-kry
    @vin-kry 3 роки тому +1

    I was looking for a video for scrollbar, And suddenly a notification popped with your video.
    Thank you ^_^

    • @nextentrepreneur9288
      @nextentrepreneur9288 3 роки тому

      Really ? I've heard that so many times, soooo unlikely...

    • @vin-kry
      @vin-kry 3 роки тому +1

      @@nextentrepreneur9288 Yes really, For SURE!!!

  • @dave6012
    @dave6012 3 роки тому

    I thought I was crazy for doing this on all my sites, but now I am validated 😀

  • @ighsight
    @ighsight 3 роки тому

    Timely input by the algorithm, was struggling with this yesterday.

  • @DavePatrick
    @DavePatrick 2 роки тому

    Helpful video as ever. I have an issue with custom scrollbars that I can't find an answer to. I often use on horizontal media scroller (you've done a video on that which is great). The problem I find though is that media scrollers will always have an overflow. But, without custom CSS for the scrollbar in an overflow:auto area, a scrollbars will only be visible when you hover on the area (on Mac and mobile devices). However when you implement custom CSS this changes and the scrollbar is ALWAYS visible. I find this ugly and non desirable, my clients and designers don't like it and tell me to get rid of it. I say that I can't because I haven't found a way! It looks bad especially when you consider often these media scrollers have padding on the left to align the first slide. Now, I would be happy with the default behaviour and would not want to use custom scrollbar CSS like you've demonstrated here, however the MAIN reason I customise the scrollbar is to get rid of the ugly Windows blocky scrollbars that you get in Chrome and Edge. Is there anything I can do, that would target the browsers that have an awful looking scrollbar? I can't think of anything atm.

  • @ЯМолодец-ъ6ш
    @ЯМолодец-ъ6ш 3 роки тому +1

    There is another one useful property ::-webkit-scrollbar-button. It could be pretty helpful to hide controls.

  • @BrianHHough
    @BrianHHough 2 роки тому +1

    This is a fantastic tutorial, thank you for making this!! Helped me so much!

  • @Glow0110
    @Glow0110 Рік тому

    Such a great, straightforward video

  • @RaveKev
    @RaveKev 3 роки тому +1

    Danke!

    • @KevinPowell
      @KevinPowell  3 роки тому +2

      Thanks so much, Kevin! (and great name 😉)

    • @Ddalu5
      @Ddalu5 3 роки тому +1

      Ehrenmann 👍

    • @RaveKev
      @RaveKev 3 роки тому

      @@Ddalu5 Danke :)

  • @thefaulenzer677
    @thefaulenzer677 3 роки тому

    Thank you so much! I really enjoy watching your videos to learn something new :D

  • @chinmayghule8272
    @chinmayghule8272 2 роки тому +1

    You can hide your scrollbar on Chrome by enabling the scroll-overlay flag. The scrollbar doesn't go away permanently, it just hides, If you place your mouse on the right edge of the screen it reappears. Also, the new scrollbar that the flag displays is thin and more stylish than the default one. Without the scrollbar websites look much better.

  • @Bobnator5
    @Bobnator5 3 роки тому

    Awesome video man! You make it so easy to understand

  • @shanehenderson8037
    @shanehenderson8037 3 роки тому

    Tried this out and worked great! I noticed my scroll bars in Firefox had rounded corners though too, so it must’ve worked!

  • @gusober4673
    @gusober4673 3 роки тому

    I learn so much with kevin powell, thanks

  • @rnwonder107
    @rnwonder107 3 роки тому +1

    Amazing stuff as always, thanks a bunch for this, I learnt a lot!

  • @akifahmed9610
    @akifahmed9610 Рік тому

    Very informative video. I was looking for customising scroll bar and stumbled upon this video 😁

  • @fittersitter
    @fittersitter 3 роки тому +23

    I remember that this was once possible in IE too. It's a nice to know. But my experience is that in most cases it isn't a good idea to change the browser UI. It disturbes the site visitors more than it improves the usability.

    • @chomo54andbabyaisha97
      @chomo54andbabyaisha97 3 роки тому +4

      I just wrote the same thing before I read this, so there must be many who remembers the scroll bar hell which came with other fun stuff like scrolling text, auto starting music. comic sans, ani gifs and "Best viewed in 680*400 with IE". History repeats itself unless we know the history and learn from it

    • @TheStickofWar
      @TheStickofWar 3 роки тому +7

      Yeah, I think this is more applicable for web apps than websites. I can see that at work making a custom scrollbar would make our inner charts that scroll a lot nicer, but I dont think I would do it on a ecommerce site for example.

    • @herion05
      @herion05 2 роки тому

      I use this for horizontal scrollers. But for the vertical scrollbar people are so used to the default one that it would be disturbing to change it.

  • @sujanbasnet7868
    @sujanbasnet7868 3 роки тому

    Super insightful video. Thanks Kevin.

  • @AbWischBar
    @AbWischBar 3 роки тому +3

    Was about to type “ha, first time ahead of you” when you started to show the Firefox hack 🤪.
    A pity Firefox doesn’t allow the full monty (one of my favorit browsers) but then you could use width = none and fake the scrollbar with a home made one (div in div and some javascript). Some might say that’s overkill, but to me unstyled scroll bars always visually pop out (mainly an issue since I am mostly a desktop XAML developer where you can style everything to fit perfectly together)

  • @CodingAfterThirty
    @CodingAfterThirty 3 роки тому

    Nice. The exact video I was looking for.

  • @DaCheat100
    @DaCheat100 3 роки тому +10

    Hate to be maintaining that code after him only to find out that the ‘.vertical-scroll’ class is responsible for the horizontal scroll bars instead 😂

  • @ashish_prajapati_tr
    @ashish_prajapati_tr 3 роки тому +1

    another thing, that i was trying to implement it on my projects.

  • @ed1nh0
    @ed1nh0 3 роки тому

    Kevin I really wish you could approach the :hover state with the width property, so we can get thin scrollbars and thicker when hovering it!

  • @creativereasons7588
    @creativereasons7588 3 роки тому

    The amount of times you drop content related to my current problem is slightly concerning.. You're a wizard..... 'Harry'.

  • @rafaelveggi
    @rafaelveggi 3 роки тому +1

    Great video, as always, thanks for the content!
    Sad thing we still can't make scrolbars to expand on hover to this day and age...

  • @CristianAlexandruRadu
    @CristianAlexandruRadu 3 роки тому

    I love your tutorials, Kevin ❤️

  • @michaelnorton6630
    @michaelnorton6630 3 роки тому +3

    Thank-you Kevin - great video as always!!👍🏻Could you also do a video on changing the header colours on mobile browers please? I've currently got this implemented on one of my sites, but not sure if there is any extra values I'm missing?!🤔

    • @KevinPowell
      @KevinPowell  3 роки тому +3

      I'll keep the suggestion in mind :)

  • @stefanpfadt4353
    @stefanpfadt4353 6 місяців тому

    Perfect timing! Thakns UA-cam algorithm :)
    Just bit bummed, I cannot get Firefox to look anyhitng like that.
    Does it work only for Edge and Chrome?

  • @MyPersonalChannel77
    @MyPersonalChannel77 2 роки тому +3

    Hi Kevin. I have a question about the vertical scrolling. The vertical scrolling inside the document, why is called vertical? Because to me, it looks like horizontal. Thanks

    • @nivethan_me
      @nivethan_me 2 роки тому

      same doubt isn't it horizontal!

  • @BabyBedtimeASMR
    @BabyBedtimeASMR 3 роки тому

    Great video can’t wait to try this!

  • @bikinglikebecker
    @bikinglikebecker Рік тому

    save: to playlist -> is not functioning on this video so unable to add to playlist.. fyi.. I presume integrating this into the style(index).css file?
    How do we make it so we can click on the page(not scrollbar) & move it up like a mac instead of scroll wheel?
    great stuff you are teaching & sharing... something we should all do with the knowledge that was shared with us by others... Concise & Articulated. Very easy to follow along & understand!

  • @antonpetrov145
    @antonpetrov145 3 роки тому +4

    Why do you call the horizontal scrollbar - vertical? Awesome video as always.

    • @KevinPowell
      @KevinPowell  3 роки тому +5

      Because I *always* mix them up, lol

    • @jeroenrnl
      @jeroenrnl 3 роки тому +3

      @@KevinPowell very easy mnemonic: horizontal is how the horizon is positioned*
      * Disclaimer: doesn't work after too many beers

  • @YxK112
    @YxK112 2 роки тому

    the explanation was unique

  • @nomad7317
    @nomad7317 Рік тому +1

    Thank you!!! You are a life saver!!!

  • @Stoney_Eagle
    @Stoney_Eagle 3 роки тому +1

    I never went this far in customizing them hehe.
    I have one that has no height on mobile where the desktop has a custom button controled scroll, too bad Firefox doesn't support exact sized bars.
    It does work with my hsl theme slider 😁😁😁

  • @hkfalguni2860
    @hkfalguni2860 2 роки тому

    Hi Kevin really nice video , covered most of them,
    I really wanted to know if we can change the color of the scroll bar on scrolling (not clicking and dragging just scrolling in the body of the page)

  • @IguanaDJ1
    @IguanaDJ1 3 роки тому +2

    Hi Kevin! Great video as always! I was wondering what fonts do you use and where can I get them? They seem very cool! Keep with the great content!

    • @KevinPowell
      @KevinPowell  3 роки тому +2

      Most of my demos use Google Fonts :)

    • @Gregorius421
      @Gregorius421 3 роки тому +3

      It's there in the codepen. For this tutorial it is:
      --ff-body: "Heebo", sans-serif;
      --ff-heading: "Oswald", sans-serif;

  • @blokche_dev
    @blokche_dev 3 роки тому +2

    I was going to ask how to style the intersection of the vertical and horizontal bars but the mozilla documentation covers that =>::webkit-scrollbar-corner. 👍

  • @aaaliii4u
    @aaaliii4u Рік тому

    Awesome Kevin!

  • @jhonataantunes5474
    @jhonataantunes5474 Рік тому

    Can you make a vídeo about nested scrolls? Maybe some columns, with individual scroll, with horizontal scroll for columns.

  • @roopisharoopi
    @roopisharoopi 2 роки тому

    Very useful video. How to set the vertical scroll thumb shape as a circle?

  • @DamnDealDone
    @DamnDealDone 3 роки тому

    How about don't mess with scrollbars? Best advice for web design anyone could ever have when it comes to scroll bars.

  • @sabiruli
    @sabiruli 3 роки тому

    You are really great, man! I like it.

  • @zqarb
    @zqarb 2 роки тому

    Thank you,
    this really helped me.

  • @SuggonM
    @SuggonM Рік тому

    2:49 that joke caught me off-guard

  • @lumynou5
    @lumynou5 8 місяців тому

    Chrome now supports the `scroll-*` properties, though these cannot change things like border radius, but I actually think it's better because in my opinion, custom scrollbars sometimes bring a bad accessibility and changing the color is enough in most case.

  • @qsaification
    @qsaification 3 роки тому

    8:38 where did you get that info? Is there a website or something?

  • @DamianWalczak
    @DamianWalczak 3 роки тому

    ohh this is what I wanted Thank You Very Much!

  • @roskildekille8972
    @roskildekille8972 2 роки тому

    Awesome! This really helped me :D

  • @rhema93
    @rhema93 8 місяців тому

    @kevinPowell I really like your soltion. It looks very good on desktop. Do you have any solution for mobile Chrome or Safari? I tested on iPhone Mobile Safari and Chrome, but wasn't able to implement those fancy scroll bars. Maybe that is idea for next video 😃

  • @hafizurrahman5341
    @hafizurrahman5341 3 роки тому

    What you do, is always interesting....♥️♥️

  • @allan_archie
    @allan_archie 3 роки тому

    Been looking for this.

  • @ayisch
    @ayisch 3 роки тому

    Liked/viewed ratio is over 10%... And still it didn’t really surprise anyone☺️👍

  • @anais380
    @anais380 8 місяців тому

    Merci beaucoup pour cette vidéo très claire 🤩
    je suis en train de faire mon portfolio et je voulais simplement un meilleur design et grâce à vous c'est parfait !
    +1

  • @Hytension
    @Hytension 2 роки тому

    I'm just happy opera supports webkit

  • @Madness-iwnl
    @Madness-iwnl 2 роки тому

    Hey man nice vid! Do you have a video on how to make a page to page scrolling option, not like an actual scrollbar.
    Let’s say for example that I’m at my index and it is based on big pictures that cover all the screen. I wouldn’t like a normal scrollbar that leaves me halfway between 2 pictures. I want to be able to scroll down from one menu to another. Thanks a lot 👌🏼

  • @baykus790
    @baykus790 Рік тому +1

    Can you somehow make the thumb flat at the top to avoid that 4:11 ugliness. Like if you scroll it down it becomes round, and flat when it touches the top, that sort of animation. Not sure if this requires JS but really appreciate if you show it in a shorts video or an actual tutorial...

  • @Leyksnal
    @Leyksnal 3 роки тому

    Thanks man.... I really appreciate this

  • @pw.70
    @pw.70 5 місяців тому

    Hi Kevin - quick question about this - is there anyway to capture the drag using CSS (i.e. when dragging the thumb -slider)? I was looking to have a grab effect running, so open hand while over the top of the thumb-slider, and closed while dragging? Thanks in advance, if you see my post. I did look down the pseudos and what-have-you, but couldn't see anything obvious.

  • @arifqasim7777
    @arifqasim7777 10 місяців тому

    can we also change the height of thumb ? and I love your videos..

  • @VasilyPavlik
    @VasilyPavlik 3 роки тому

    Good topic as usual, Kevin. But you forgot about arrows. They could be also styled.

  • @nomadshiba
    @nomadshiba 3 роки тому

    i use thin scrollbar on small stuff, for example a card for previewing a post but tags doesnt fit on a single line so you can just scroll it to left or right, because the card has to be a specific aspect ratio.
    if i dont make it thin, it looks really ugly on pc

  • @rushwand
    @rushwand Рік тому

    can you please make a tutorial how to make the scrollbar on top of the div?

  • @enriquesneffels3053
    @enriquesneffels3053 2 роки тому

    Hello, Kevin! How can we make the 'thumb' a little bit smaller? I have been looking, but I haven't found anything and he MDN documentation is awful on this topic, they don't even provide examples to most of the options they listed. I wanted to make one rounded instead of a 'pill' shaped one. And I was wondering if I could add maybe a triangle or an icon instead of the default shape.

  • @conceptrat
    @conceptrat 3 роки тому

    Just wondering if the reason the margin-inline didn't work on the scrollbar-track is because it can't expand past the 2em you've set on the scrollbar element?
    So you'd increase the scrollbar element or add margin to it instead.

  • @MKgobe
    @MKgobe 3 роки тому

    Finally... My scrollbara where just missing that @supports,

  • @toncizizic
    @toncizizic 3 роки тому +1

    How did he write on 4 places at once at 6:25

    • @BasicallyWiz
      @BasicallyWiz 3 роки тому

      Some IDEs support a multi-caret typing system. If what he's using is anything like VSCode, you can create multiple carets using CTRL+ALT+up (or down), or what he's done can be replicated in VSCode by holding ALT and clicking a character in a script.

  • @AhmedAzmizem
    @AhmedAzmizem Рік тому

    Hi Kevin, I really hope you read this comment x)
    I just have a question, is there a way to make the scrollbar thumb width increases on hover? I just couldn't make it, since the scrollbar already have its own width.

  • @lonewolfcoding5208
    @lonewolfcoding5208 2 роки тому

    can you create a table with border radius
    with horzontal and vertical scrollbar
    and the headers are fixed?

  • @reignsvicky
    @reignsvicky 3 роки тому

    New thing learned today 🤩

  • @djelasrca8091
    @djelasrca8091 3 місяці тому

    How to make scrollbar not pushing the content to the left. Can it have something like position absolute

  • @dixztube
    @dixztube 2 роки тому

    I’m having issues with edge showing the scroll even when the window isn’t active. Seems like Firefox makes it hide till being used

  • @iroshanaravishan1388
    @iroshanaravishan1388 2 роки тому

    Wow.. thanks.. it works perfectly🤩🙌🏁

  • @SACreator
    @SACreator 2 роки тому

    Can we have thumb:hover effect to animate change color like we do with keyframes ? is that possible thanks.

  • @agnos76
    @agnos76 3 роки тому

    How can a scrollbar width transition be used? I know that it is possible to use a transition for color using inherit, but this cannot be repeated with width.

  • @monuchouhan8311
    @monuchouhan8311 3 роки тому

    That's beautiful!

  • @mufeezhanif
    @mufeezhanif 2 роки тому

    Nice explained..!

  • @guillermoandradaFSD
    @guillermoandradaFSD 3 роки тому

    I find your vids really usefull

  • @brokensythe
    @brokensythe 3 роки тому

    Fantastic video