We can now transition to and from display: none

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 29. 06. 2024
  • Start writing CSS with confidence 👉 cssdemystified.com/?...
    🔗 Links
    ✅ Great article from Chrome for Developers blog on this : developer.chrome.com/blog/ent...
    ✅ Open Web Docs: openwebdocs.org/
    ⌚ Timestamps
    00:00 - Introduction
    00:40 - Using keyframes to animate the display property
    04:45 - What you might try to get transition to work
    05:58 - What is a discrete animation
    08:13 - Open Web Docs
    09:00 - Using transitions to go to and from display: none
    10:55 - CSS Demystified
    11:30 - Using @starting-style
    12:30 - Easily have different transitions in each direction
    13:52 - Browser support and progressive enhancements
    16:12 - Make sure you include overlay for popups and dialogs
    17:25 - The problem with peudo-elements, including ::backdrop
    #css
    --
    Come hang out with other dev's in my Discord Community
    💬 / discord
    Keep up to date with everything I'm up to
    ✉ www.kevinpowell.co/newsletter
    Come hang out with me live every Monday on Twitch!
    đŸ“ș / kevinpowellcss
    ---
    Help support my channel
    👹‍🎓 Get a course: www.kevinpowell.co/courses
    👕 Buy a shirt: teespring.com/stores/making-t...
    💖 Support me on Patreon: / kevinpowell
    ---
    My editor: VS Code - code.visualstudio.com/
    ---
    I'm on some other places on the internet too!
    If you'd like a behind the scenes and previews of what's coming up on my CZcams channel, make sure to follow me on Instagram and Twitter.
    Twitter: / kevinjpowell
    Codepen: codepen.io/kevinpowell/
    Github: github.com/kevin-powell
    ---
    And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Komentáƙe • 187

  • @MaksymCzech
    @MaksymCzech Pƙed 23 dny +334

    Finally, it took only 20 years 😂😂

    • @royhyde8842
      @royhyde8842 Pƙed 23 dny +3

      Hhahahahhha Riiiiight!!!!

    • @jugibur2117
      @jugibur2117 Pƙed 23 dny +11

      28 years, to be exact 😁

    • @GyroCannon
      @GyroCannon Pƙed 23 dny +6

      For people targeting Firefox, it’ll take another year, apparently

    • @chezchezchezchez
      @chezchezchezchez Pƙed 23 dny

      And if you were running the show, you would’ve had it done in two years? Give me a break, dude.

    • @saintpumpkin
      @saintpumpkin Pƙed 21 dnem

      since display property had no numeric value it was supposed not to translate

  • @farhan-app
    @farhan-app Pƙed 23 dny +63

    "We have display transitions before GTA 6"

  • @mubrik_
    @mubrik_ Pƙed 23 dny +60

    Wow, I never thought this day would come

  • @Yous0147
    @Yous0147 Pƙed 23 dny +45

    It's pretty incredible how almost every difficulty I find in CSS gets addressed by your videos handedly. Awesome stuff

  • @codeslacker77
    @codeslacker77 Pƙed 22 dny +10

    Wow, finally~!!! The days of width/heigh/margin/paddingt: 0px; opacity:0; pointer-event:none; finally comes to an end

    • @nitsanbh
      @nitsanbh Pƙed 6 dny +1

      Also tabIndex="-1" and overflow: hidden

    • @codeslacker77
      @codeslacker77 Pƙed 5 dny

      @@nitsanbh Yes, this one too.

  • @you_cant_see_me_3000
    @you_cant_see_me_3000 Pƙed 23 dny +30

    Today is a good day! I felt it in my bones when I woke up this morning!

  • @joshcool
    @joshcool Pƙed 19 dny

    I've been waiting for this for YEARS lol so happy about this!

  • @christian-schubert
    @christian-schubert Pƙed 22 dny +9

    Jebus, Web Dev has gotten so easy these days!
    SO glad we've got all these Frameworks that overcomplicate matters again

    • @paxdriver
      @paxdriver Pƙed 21 dnem +1

      Lmfao, well, to be fair I used to be able to teach every single possible style attribute and value in a month and have them all memorized. Now I can't do half of css without gpt or the docs because everything has a specific name and specific limits (like vh not accounting for mobile browser address bars, or justify content vs justify item).
      This is harder than it's ever been, but we've never had so much broadband internet, search and LLM tools to help navigate it on the fly.
      We dev used to be way way easier though, we could build websites in notepad without a linter or IDE. No joke I did it for like 6 years in notepad.

    • @TheWhoreDetector
      @TheWhoreDetector Pƙed 19 dny

      @@paxdriveras someone starting coding / programming I agree, of course the more I do it gets easier but it should be more simplified imo

  • @intsfanatic
    @intsfanatic Pƙed 23 dny +18

    But we still cant transition to height auto...

    • @Killyspudful
      @Killyspudful Pƙed 23 dny +8

      There's an upcoming CSS value which will allow that -. height: calc-size(auto);, for example. Under development in Chrome, I believe.

    • @duruiz
      @duruiz Pƙed 23 dny +7

      unfortunately :(
      but we can do a css only solution with grid :)

  • @mur9a
    @mur9a Pƙed 23 dny +7

    The amount of animation that are going to be made in the next 2 hours by me is going to be ungodly

  • @pinkseacow6067
    @pinkseacow6067 Pƙed 23 dny

    Allways great Videos you make! Happy to have you💙

  • @LePhenixGD
    @LePhenixGD Pƙed 20 dny

    This is amazing! I've been waiting for years for this feature to come, can't wait for browser support to be good enough for me to start using it!

  • @WillHuizenga
    @WillHuizenga Pƙed 23 dny +2

    Looking forward to playing with this tomorrow
    Very glad I watched to the end. That last bit of information will be very useful.

  • @albedesigns
    @albedesigns Pƙed 23 dny +1

    I truly appreciate your videos. They've helped me so much! ❀

  • @luc122c
    @luc122c Pƙed 23 dny

    Thank you so much. I needed to do this today! I really appreciate you taking the time to cover the details and the caveats.

  • @heyyounotyouyou3761
    @heyyounotyouyou3761 Pƙed 23 dny +12

    Thank you so much css devs, really needed this so bad. Had to use settimout and it was killing me everytime I wrote it

    • @graysonpeddie
      @graysonpeddie Pƙed 22 dny +2

      Yeah, and I don't want to use JavaScript in my website if I don't want to and my website does not use it at all! Only HTML and CSS! :D

    • @heyyounotyouyou3761
      @heyyounotyouyou3761 Pƙed 22 dny +1

      @@graysonpeddie that's plane wierd. Static websites are a thing of the past

    • @TheWhoreDetector
      @TheWhoreDetector Pƙed 19 dny

      @@heyyounotyouyou3761nothing wrong with static websites 😊

  • @samurai1122
    @samurai1122 Pƙed 23 dny +2

    Great news. I was waiting for this and I have a few drop-down elements with display none :)

  • @kolsark422
    @kolsark422 Pƙed 23 dny

    this looks clean af to use, thx a lot Kevin ! Can't wait for it be better supported

  • @brankoh
    @brankoh Pƙed 22 dny

    Finally!!!! Thanks for the heads up.
    As always, great video! That's why you are one of my sources of info when I need to update coding knowledge.

  • @robomalo
    @robomalo Pƙed 23 dny

    Crazy timing. I legit just found this two days ago for changing content visibility.

  • @samraavana
    @samraavana Pƙed 22 dny

    My first video was on 223k, now looks how much it grows. Because of you life is becoming easier and easier thank you.

  • @keenanflogerzi5218
    @keenanflogerzi5218 Pƙed 22 dny

    Thanks for the explainer on discrete animations, and the “allow-discrete” transition-behavior.
    I saw another video mention that property but I didn’t understand because it didn’t explain what that is or how it works. Thanks for yet another excellent video!

  • @arthuradriansens3291
    @arthuradriansens3291 Pƙed 23 dny

    You just made my day, thx!! Finally

  • @GilGoldshlager
    @GilGoldshlager Pƙed 22 dny

    THIS IS THE BIGGEST NEWS IN CSS EVER!!! đŸ˜Č I'm still shaking! can't believe this is real! thank you so much 💗🙏

  • @alanbloom20
    @alanbloom20 Pƙed 23 dny

    Really well constructed way to explain through this concept. I’d say that it’s one of the trickiest concepts I’ve had to deal with and you’ve revealed some quirks about this process that reveal why some things weren’t working in the past. Thank you :-)

  • @seba-aranda
    @seba-aranda Pƙed 18 dny

    great video! Thanks for taking the time in explaining the little details, those were really usefull 🙏. I was looking for this kind of explanation because I knew this was new, but after some tries I was not being able to animate the display property 😆, now I can 😎.

  • @itlackey1920
    @itlackey1920 Pƙed 13 dny

    Great explanation, and very helpful as always. Thank you!

  • @akramilyas6030
    @akramilyas6030 Pƙed 23 dny +1

    yaaaaaay now this and page transition , anchor position , container query we will be happy

  • @AnkitTannaVlogs
    @AnkitTannaVlogs Pƙed 20 dny

    The way Kevin explains complex concepts ❀❀❀

  • @Jumanji_Dev
    @Jumanji_Dev Pƙed 18 dny +1

    Finally Maahn 🎉🎉 đŸ•ș

  • @_hepl
    @_hepl Pƙed 23 dny

    Oh gosh! Thanks, finally!

  • @ericdimarzio5756
    @ericdimarzio5756 Pƙed 12 dny

    Love the content, Kevin! Wanted to let you know there’s an ad break right in the middle of the plug you make for your course. Probably not good for click-thru’s. Your content is amazing and needs to reach as many people as possible. 😊

  • @Pukmeister0
    @Pukmeister0 Pƙed 20 dny

    Holy hell, thank you so much for this

  • @Linuxdirk
    @Linuxdirk Pƙed 19 dny

    I instantly know some of my sites that could use this and where it would make things 100% easier! 👍

  • @koreappinesmusic
    @koreappinesmusic Pƙed 22 dny

    Love your Content, Thank you.

  • @deadlyecho
    @deadlyecho Pƙed 23 dny

    Wow that is so powerfull and will make things alot easier

  • @RichardCalder67
    @RichardCalder67 Pƙed 23 dny +2

    Watching the Can I Use part all of a sudden reminded me of having to have a work around for border radius lol.

  • @jfftck
    @jfftck Pƙed 23 dny +1

    So to have the animation in all browsers, it would take a little JavaScript to listen for the animationend event and would also mean that transitions wouldn’t work still. This is how it’s been done before these properties, so you could still support this and use the supports method of CSS in JavaScript to disable if the new properties are supported, this has a benefit of being able to track the percentage of browsers that require JavaScript to work and this doesn’t need any additional analytics tool to do that. You could send the information back to the server and compare to the number of hits the other endpoints receive to get a rough estimate for your site.

  • @LouisCharlesBlais
    @LouisCharlesBlais Pƙed 23 dny

    What a time to be alive ✹

  • @paxdriver
    @paxdriver Pƙed 21 dnem

    For the record, it is faster to learn javascript and do anything you can imagine vs learning css and spending a lifetime learning new, old, cheat-cut rules that javascript solved decades ago.
    I love this channel, I use css every day, but javascript took a couple years to learn while I'm always trying to catch up to css to do things I could already do in js.
    The reason why it's important to keep up with css is gpu acceleration, react, and it's just plain fun. But seriously, for people who avoid javascript because it's hard to learn or complicated, if you can learn css you'll be a beast at javascript. Being able to do both makes you an expert with no limits but imagination.

  • @tonyvito5062
    @tonyvito5062 Pƙed 6 hodinami

    Finally that's really useful

  • @raphaelgoetter
    @raphaelgoetter Pƙed 23 dny +4

    Are you sure `transition-property: opacity display;` is working? Values shoud be comma separated

  • @artursavchuk2363
    @artursavchuk2363 Pƙed 6 dny

    thanks, this information is very useful

  • @nothappyz
    @nothappyz Pƙed 23 dny +2

    Thank you css daddy 😭

  • @Horse-tradeEu
    @Horse-tradeEu Pƙed 17 dny

    The keyframes method which is basically the only one working cross-browser, requires backdrop set to none. 1. That removes the focus that is required for the animation but defeats the whole accessibility purpose. Also then 2. you need to set your event to window if you want the modal to disappear when you click the backdrop. 3. Of course the easy customization of the backdrop color. I liked the video cause I am big fan of Kevin but unfortunately as exciting as it looks, we need better support on this. It's a nice feature.

  • @spikeganush
    @spikeganush Pƙed 20 dny

    Great video, as usual.
    I think in transition-property each property needs to be separated by a coma!
    transition-property: display, opacity, overlay;

  • @MattDawkins-gh6gi
    @MattDawkins-gh6gi Pƙed 18 dny

    Interesting. Though I'm not sold on the logic behind "transitioning" the display property. It's more like controlling the timing of when that discrete property applies, there's no in-between state. Personally, in this example, I'd probably just use `opacity: 0` to make the popup invisible and `pointer-events: none` to ensure it can't be interacted with when it's invisible. But that @starting-style looks like it could have lots of uses! Thanks for sharing.

  • @jonmayer
    @jonmayer Pƙed 23 dny

    About flippin' time!

  • @akash-kumar737
    @akash-kumar737 Pƙed 23 dny +2

    I can't tell how much I need it. Must needed to animate modal.

  • @lronmate
    @lronmate Pƙed 23 dny

    Miracles do happen 😼

  • @xaddict
    @xaddict Pƙed 16 dny

    transition-property is officially supposed to be a comma-separated list, that's why the devtools were saying it's wrong.

  • @JohnFarrellDev
    @JohnFarrellDev Pƙed 21 dnem

    Whoooa, bought in framer motion to achieve this for a big project before.

  • @nazmulalok9404
    @nazmulalok9404 Pƙed 19 dny

    So glad to see this, But I am wondering how can I use in a faq using details & summary, Thank you so much Kevin.

  • @ajxtc2
    @ajxtc2 Pƙed 16 dny

    You can use pointer-events:none on overlaying invisible modal and transition from there

  • @ennioVisco
    @ennioVisco Pƙed 18 dny

    Thanks a lot Kevin! Now that you mentioned it btw, what about a video on the gotchas between css nesting and sass? I remember you did one in the early days, but the spec became a little more permissive since then

  • @RickBeacham
    @RickBeacham Pƙed 23 dny +3

    Thanks!

  • @RonaldGrootJebbink
    @RonaldGrootJebbink Pƙed 23 dny

    Finally! Also great background news with how it works. I have a question about multiple dialogs. Do you know if it is possible to only use one ::backdrop with a color instead of all. I want the functionality to open two dialogs at the same time, but because the ::backdrop is stacking, the website beneath is getting more and more darker. Just curious if you know what I mean and if you have a creative solution to this :).

  • @mistabuzz5485
    @mistabuzz5485 Pƙed 17 dny

    Now I know how framer motion works. Seems like I can get a lot more control doing in this way though.

  • @n-0-1
    @n-0-1 Pƙed 22 dny

    Now we need a transition between justify/align content/items start/center/end.

  • @Ray-es1r
    @Ray-es1r Pƙed 22 dny

    CSS must be the most ill conceived visual/styling language, and I use the term loosely, in popular use today. You'd think W3C at some point would start work on a clean slate approach rather than retrofit every useful feature into CSS. "if you do this you have to remember that but avoid that and this will work in this direction unless you do that in which case you need to do it the other way you can do it but that doesn't work in that other case".

  • @jugibur2117
    @jugibur2117 Pƙed 23 dny

    Thanks for this introduction! Although my old head is already pretty full with all the commands and rules... not only for CSS đŸ€­

  • @benson6158
    @benson6158 Pƙed 23 dny

    Oh this is new?
    I’m just getting into really learning web development (I come from RF test automation) and used this in my first little project. Assumed it was just the normal way to do this.

  • @Daniel_H01
    @Daniel_H01 Pƙed 22 dny

    thats awesome.

  • @Jeckwilke
    @Jeckwilke Pƙed 23 dny

    finally!!!!!!!!!!!!

  • @MrEnvisioner
    @MrEnvisioner Pƙed 15 dny

    20:20 Maybe not worth it for just one property and a simple 'dialog[open]' selector, BUT it should still be possible to use nesting for the @starting-style if you segregate the pseudo-element reference using the combine '&' operator for both cases. That way, you can independently maintain the selector for the parent context, like this:
    dialog[open] {
    &::backdrop {
    opacity: .75;
    }
    @starting-style {
    &::backdrop {
    opacity: 1;
    }
    }
    }

  • @C0playeR
    @C0playeR Pƙed 23 dny

    Finallyyyy

  • @gilsonconceicao5201
    @gilsonconceicao5201 Pƙed 23 dny

    Thanks

  • @MaxWeir
    @MaxWeir Pƙed 20 dny

    Perfect timing, we recently converted to dialogue for all our modals, this will be a nice upgrade 🙂
    I was asked by our lead dev to convert our off-canvas to a dialogue as well, I however think this is not the appropriate use case and may cause some usability issues?
    AlsoI noticed your link in the desc. isn't formatted correctly - the query string isn't part of the link anymore.

  • @legostud
    @legostud Pƙed 23 dny

    Key frames are also global so be careful what you call them to prevent accidental overrides.

  • @lukasmolcic5143
    @lukasmolcic5143 Pƙed 23 dny +2

    One thing you can do if you want this effect to work in all browsers without using .js would be to not use display none at all, but just keep the opacity animation for animating back and forth, but then also add ponter-events: none to the hidden state so that it doesn't block any mouse events going over it.

  • @starmechlx
    @starmechlx Pƙed 22 dny

    I've never clicked on a thumbnail so fast

  • @lucascubile7141
    @lucascubile7141 Pƙed 12 dny

    Nice they starting to add stuff like this but I wouldn't implement it yet for compatibility stuff.

  • @kill_switch_101
    @kill_switch_101 Pƙed 11 dny

    tnx a lot

  • @Xamy-
    @Xamy- Pƙed 23 dny +1

    Ayooo finally

  • @hitmusicworldwide
    @hitmusicworldwide Pƙed 23 dny

    Claude Opus just did this for me to create luminous slide up price cards last week

  • @Say_whaaaaat
    @Say_whaaaaat Pƙed 22 dny

    Getting ready for a bunch of fade in sites now

  • @MrHerbalite
    @MrHerbalite Pƙed 23 dny

    đŸŽ‰â€awesomeđŸŽ‰â€đŸŽ‰

  • @ajiteshmishra0005
    @ajiteshmishra0005 Pƙed 7 dny

    Could you please create one video explaining full Tailwind CSS and also comparison of CSS with Tailwind CSS???

  • @luichyluichy
    @luichyluichy Pƙed 21 dnem

    I hate having to wait for new features like this hahaha

  • @deatho0ne587
    @deatho0ne587 Pƙed 23 dny

    Really wish legacy code bases could use this and modal/pop-up from the newer HTML stuff.

  • @graysonpeddie
    @graysonpeddie Pƙed 22 dny

    starting-style... Hopefully Firefox will support that in the future. Firefox seems already behind compared to Chromium-based browsers...

  • @tim-pn2fq
    @tim-pn2fq Pƙed 23 dny +3

    At 13:10, can somebody tell me why translate is animating even though we are only specifying transition-property display and opacity?

    • @tim-pn2fq
      @tim-pn2fq Pƙed 23 dny +3

      Edit: it looks like transition-property takes a comma separated list, and has an initial value of 'all'

    • @stefanjudis
      @stefanjudis Pƙed 20 dny

      @@tim-pn2fq I was wondering the same. Thanks for digging this up. :)

  • @typicalyorkshirebloke
    @typicalyorkshirebloke Pƙed 23 dny +2

    If I was trying to implement this into a typical navbar then, where clicking the hamburger icon shows or hides the links in the navbar, would this still work this way? Instead of opening with one element and having to click another element to hide it again. Appreciate the videos always!

  • @titusayyasamy3035
    @titusayyasamy3035 Pƙed 19 dny

    Dialog with transition, good. but you forgot to show us button onclick method by the way 🙂

  • @Jedediahiah
    @Jedediahiah Pƙed 23 dny

    Great video as always! Curious as to why the translate: 0 -25vh; animates without being specified as a transition-property?

  • @backup_hdd
    @backup_hdd Pƙed 23 dny +1

    wait, why does translate animate despite not being mentioned in transition-property? and what, you can define transition-properties without a comma in between? :o

  • @l1f3l3s2
    @l1f3l3s2 Pƙed 12 dny

    Can you make a roadmap of your videos/playlist to learn CSS?

  • @user-gi3oc1kv5m
    @user-gi3oc1kv5m Pƙed 23 dny

    Super cool! How does this affect accessibility? 👀

  • @dealloc
    @dealloc Pƙed 23 dny

    My thinking is that this was pushed until dialog spec was done (it was a proposal since at least as early as 2011). Simply because dialog _relies_ on display property for its visible state, rather than opacity/visibility , which would prevent interaction with underlying elements.

  • @epictechshorts
    @epictechshorts Pƙed 23 dny +1

    Big fan ❀❀❀

  • @XCanG
    @XCanG Pƙed 23 dny +1

    Will it work in this case?
    dialog {
    ...
    &[open] {
    ...
    &::backdrop { ... }
    @starting-style { /* dialog starting styles */ }
    @starting-style &::backdrop { /* dialog backdrop styles */ }
    }
    &::backdrop { ... }
    }

  • @ebenezerowusu1680
    @ebenezerowusu1680 Pƙed 23 dny

    My best teacher đŸ”„đŸ€©đŸ„ł

  • @coffeemakir1977
    @coffeemakir1977 Pƙed 23 dny

    If they fix margin-top my bucket list will be complete

  • @antonio_carvalho
    @antonio_carvalho Pƙed 22 dny

    This is exactly what I needed, but it isn't animating when I close() a dialog on Safari (v 17.5), not even in the example on the "transition-behavior" website on MDN.

  • @backup_hdd
    @backup_hdd Pƙed 23 dny

    ah yes, "yes", my favorite animation type

  • @marksyzm
    @marksyzm Pƙed 20 dny

    I used to use delay of N seconds and a 0 second animation on the display property to get around this. I guess this method is somewhat more straightforward but the starting-style syntax looks a bit awkward. I’m sure I’ll get over it.

    • @marksyzm
      @marksyzm Pƙed 20 dny

      Nice to have a simple version of from
to like in the animation key frame syntax though with “starting-style”!

  • @pascalmaranus
    @pascalmaranus Pƙed 23 dny

    So wouldn't you have been able to add a nested &::backdrop within the previously set @starting-style?

  • @dj10schannel
    @dj10schannel Pƙed 22 dny

    Hmmm đŸ€” never thought this would be added lol

  • @Bilo_7
    @Bilo_7 Pƙed 20 dny

    Ou ou ou. Memories are flashing in front of me. Back then when i almost cried from frustration because of the sucking transition for display none 😂

  • @lucadetomi9269
    @lucadetomi9269 Pƙed 16 dny

    Please, how to combine this technique with your solution for accordions made using grid-layouts and transitioning from 0fr to 1fr?