Stop animating box-shadows the wrong way!

Поділитися
Вставка
  • Опубліковано 12 січ 2025

КОМЕНТАРІ • 89

  • @leonardomorel9412
    @leonardomorel9412 4 роки тому +32

    This is my third month being a self-taught student and this channel is gold, your videos help me immensely. Thanks for the content!

  • @cintron3d
    @cintron3d 4 роки тому +21

    *TLDW:* Pre-render your shadows on a pseudo element and animate it's opacity to improve performance. Chrome DevTools has a performance monitor tab where you can see the impact of your CSS design. Opacity and Transforms are MUCH cheaper to animate than position, shadow, etc...
    Bonus: Shadows are tied to their respective element's z-depth.
    Thanks for the content Kevin! That's actually a neat approach I hadn't thought of and I should really start looking at the performance monitor more when designing.

  • @support2587
    @support2587 4 роки тому +5

    It's like going down a rabbit hole, one video leads to the next! Nice work I'm finding new things every day.

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

    hi kevin, gr8 tip. thank you. one thing though, you need to set the pseudo element that is positioned absolutely to either z-index:-1 or pointer-events to none, otherwise you can not click on the links in the box. :)

    • @ion-claudiutanase7850
      @ion-claudiutanase7850 4 роки тому

      Totally agree on that. The link inside .pseudo-hover is unreachable...

  • @violet-trash
    @violet-trash 4 роки тому +16

    Oh no. Buttons on my site have been using top:; this whole time. 😅 Can you do a video on general performance tips and best practices for CSS?

  • @PHEELL822
    @PHEELL822 4 роки тому +12

    We need a series for learning how to use the performance tool!

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

    I'm from South Africa and we currently have 'Loadshedding' (areas have their power turned off to cut back on power consumption because the power utility company is owned by the government and are a bunch of mizers) and I have just sat for 2 hour, in the dark, going through all your videos. The explanations are clear and you have some really great tips and tricks! Keep up the great work! Really enjoying this content!

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

    I remember trying to animate buttons and shadows to make a hover effect and everything was slow as a turtle, and I didn't understand why xD Good to learn how I can surpass these problems, thanks as always, Kevin!

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

    Wow that's my geek-o-meter fill for the morning!! That was crazily interesting, I will be utilising the dev tools much more from now on - cheers Kevin!

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

    I believe the performance is higher because the transform and opacity properties are GPU accelerated. Awesome tips Kevin!

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

    That was really useful info for me! I didn't realize that most transition that I made was performance heavy even though I saw how laggy it is. Thanks!

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

    Added to my list of global things to do for my site. Will come back and watch again soon while implementing. Thanks, Kevin!

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

    What a video! Can't get enough of this. Absolutely gold info

  • @lawrenceardosa1730
    @lawrenceardosa1730 4 роки тому +1

    I think you can replace top:0; left:0; right:0; bottom:0; with just inset:0; and it will still work the same.

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

    ahhhhh this video is AMAZING. I didn't know I needed this at all.

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

    thanks for showing how to measure the performance of these animations

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

    Thankyou Tobias and Kevin, I needed this in my current project, so, WOW!

  • @crawfordvining4208
    @crawfordvining4208 4 роки тому

    great breakdown regarding animation performance in the dev tools! that will come in handy. thanks!

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

    Mind blown. I have been doing it all wrong. I often forget to use the performance tab so this was great reminder.

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

    Wow, this is a great approach! I tried this on my site and rendering/paint time went from about 50ms both to about 6ms and 2ms. Thanks!

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

    this is a great explanation... been a dev for years now and still didn't know how to use the performance tab LOL

  • @robertotonino2916
    @robertotonino2916 4 роки тому

    This is the type of content I really like, small performance tips which put together improve UX!

  • @franco-cespi
    @franco-cespi 4 роки тому

    Awesome, as usual. This will come in handy for my next work. Just on time Kevin. Thanks!

  • @kevinmc5249
    @kevinmc5249 4 роки тому

    Thanks for the video, and bringing this info to our attention. Well done as always.

  • @axMf3qTI
    @axMf3qTI 4 роки тому +17

    I need that shirt!!

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

      I got it from here moderngeek.co/
      They have some great stuff!

    • @bobsfriend12
      @bobsfriend12 4 роки тому +9

      Roses are red
      Violets are blue
      unexpected '}' on line 32

    • @unchart_d
      @unchart_d 4 роки тому +1

      Me too😂

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

      Dang it, the site no longer exists! Any other suggestions?

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

    Very nice one thank you ! I've learned so much on CSS performances on that video

  • @FRONTRUS
    @FRONTRUS 4 роки тому +11

    I'm the only one when I go to the video immediately put the like automatically?

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

      Sorry, but you're not the only one. I know someone who did too. He used to wonder the same.
      That someone is mush😊

  • @RussDnB
    @RussDnB 4 роки тому

    One of the best tutors out there. Thank you Kevin :)

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

    I just tried a third option with drop-shadow. And box-shadow outperforms the filter too. I thought they were fast too 🤯

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

    > a teenager, in the late 90s...waiting for images...to load--
    I felt that.

  • @luongkhai6435
    @luongkhai6435 4 роки тому

    Wow. This is new aspect to learn about HTML and CSS

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

    What if there is already a box-shadow of a container and on hover the box-shadow should turn inset, How can we do this by the technique shown by you??

  • @ev721
    @ev721 4 роки тому

    KP delivers once again!!!

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

    Do you have any tips for the jittery text inside the boxes that have transform animated? Thanks for the tip on the box-shadows, just did the exact thing wrong the other day, so need to fix it asap!

    • @KevinPowell
      @KevinPowell  4 роки тому +1

      I'm not sure if there is much we can do there sadly. Or if there is, I'd love to know!

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

      @@KevinPowell I've been suffering from this problem for so long. Texts, icons... whatever I animate transform property on it gets blurry. It's horrible especially when creating infinite animation with keyframes. Any tips or a dedicated video regarding this problem will be very much helpful for someone like me.

  • @patrickc.6183
    @patrickc.6183 4 роки тому

    Great video man! Nice use of the Chrome performance tools as well 😃!

  • @LanFeusT23
    @LanFeusT23 4 роки тому

    Nice video! I ended up having to do something like that today and remembered about your video! Worked great, thanks!

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

    Hi Kevin, Thanks for this once-again very informative tutorial in CSS and the performance gains by using this method for implementing box shadows.
    I have applied this to a WooCommerce Product Archive Query loop which causes the 'Add to Cart' and 'Product link' links to become unaware or displaced. I presume it has something to do with the absolute positioning. Would you mind sharing some advice on how to counteract this behaviour please?

  • @francolamattina1803
    @francolamattina1803 4 роки тому

    these tips are so powerful, ty!!

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

    Okay. All fine and dandy. But what if you have some buttons/links inside the div? They get covered by the pseudo element.

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

    Great video again! Can you make crash course on Styled components I like the way you teach 😄

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

      I don't have very much experience with them :\

    • @sarcasticdna
      @sarcasticdna 4 роки тому

      @@KevinPowell oh it is okay 😊.

  • @ukaszzbrozek6470
    @ukaszzbrozek6470 4 роки тому +1

    Really great video!

  • @podiac
    @podiac 4 роки тому

    I really aopreciate your way of teaching. Thank you so much

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

    When is it good to use will-change? Last I read on it was to not use it unless you've already run into performance issues. I've used it a bit, but perhaps a bit too often.

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

    i have a question:
    the way you did hover for performance was best way i ever saw of... but.
    Q: the elements inside the box are now un-clickable like links and buttons, etc.. so is there a way to make it work with high performance way you showed but the links and all contents are clickable? can we do it with z-index?(i tried it but i might have done it wrong.. dosen't work for me) or is there some other way?

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

    This video was very useful for me, thanks for sharing

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

    Love your yeti mic : )

  • @ibrahimmanaf
    @ibrahimmanaf 4 роки тому

    Hello KP, I tried the pseudo card and it is nice, but if there is a link on the card, is it clickable?

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

    Aren't both of the shadows showing on top of each other on hover? The one that's there always, and the hidden pseudo one you give the opacity 1 on hover. Or maybe I'm missing something... By the way, love all of your content, keep going :)

  • @yashptel
    @yashptel 4 роки тому

    Hi, I am trying to make en extension that zooms to fill videos on most sites. I am using transform scale for zooming the videos for sites like UA-cam, Netflix, etc. It lags for a higher quality video on my laptop. Is there a better way to animate scaling on a video?

  • @cooroanima4519
    @cooroanima4519 4 роки тому

    Hi. What coloured spot lights are you using for your background? It looks really good.

  • @bikramjeetsingh4943
    @bikramjeetsingh4943 4 роки тому

    hey kevin, can we do it for background setting the opacity from 0 to 1 by rgba

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

    Great video, but you need to put pointer-events:none; on the pseudo-element, or else you can't click on anything in the second div since it's covered by the pseudo-element.

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

    The problem is that the pseudo element covers the original card making it unclicable.

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

    I liked ur t-shirt btw.

  • @tonyr.6637
    @tonyr.6637 2 роки тому

    Love that shirt 🤓

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

    Just wondered why you using top, right, left, bottom zero :D Then i saw this is 2 years old. Now you would use inset: 0; instead.

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

    shirt checks out lol

  • @fazlerabbirana993
    @fazlerabbirana993 4 роки тому

    Hi Kevin, this video is awesome. But there is a problem that I've been facing for so long and still can't find a proper solution. The problem is:

    The box contents (texts) are getting blurry while transforming. Is there any solution for this? Please help.

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

      Yeah, it's an issue. Often depends on the transform. If there is a solution I don't know what it is

    • @fazlerabbirana993
      @fazlerabbirana993 4 роки тому

      @@KevinPowell Oops...didn't see that coming. I hope you will try and be able to figure that out.
      BTW thanks for your quick response.

  • @pkgacek
    @pkgacek 4 роки тому

    Kevin, i love your videos. Please consider moving mic somewhere else - it looks like you have a black eye (due to its Shadow on your face)

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

      yeah I know, it'll be fixed next time, lol

  • @Ostap1974
    @Ostap1974 4 роки тому

    These tricks are very good to know.
    But to be honest, I don't understand the real reson why transform should actually outperform the top. There is no more algorithmical complexity, if anything, changing top should be simpler to implement efficiently (by browser).

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

      Opacity and transforms are GPU accelerated, and also cause few repaints. Most other things shouldn't be animated if possible.

  • @أخباركروية-ظ4ص
    @أخباركروية-ظ4ص 4 роки тому +1

    Wow nice

  • @ck0024
    @ck0024 4 роки тому

    Awesome stuff

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

    5:47 happily:hover::after

  • @sebaszwarc6028
    @sebaszwarc6028 4 роки тому

    Nice t-shirt :)

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

    loved the img joke xD

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

    Came for animation, got transform 😛

  • @rahul-thakare
    @rahul-thakare 4 роки тому

    AWSM!.

  • @thecscontent5110
    @thecscontent5110 4 роки тому +1

    I also do videos about programming!😁

  • @siddhant_445
    @siddhant_445 4 роки тому

    ❤️

  • @cannonblasters5957
    @cannonblasters5957 4 роки тому

    You are a pro

  • @sjn_
    @sjn_ 4 роки тому

    Lol epic t shirt

  • @Unknown-yt7zu
    @Unknown-yt7zu 4 роки тому

    For fast animations: animate shadow opacity instead of animating shadow size. It's realy annoying to watch all 14 mins for such a small info...