We can now transition to and from display: none
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!
Finally, it took only 20 years đđ
Hhahahahhha Riiiiight!!!!
28 years, to be exact đ
For people targeting Firefox, itâll take another year, apparently
And if you were running the show, you wouldâve had it done in two years? Give me a break, dude.
since display property had no numeric value it was supposed not to translate
"We have display transitions before GTA 6"
Wow, I never thought this day would come
It's pretty incredible how almost every difficulty I find in CSS gets addressed by your videos handedly. Awesome stuff
Wow, finally~!!! The days of width/heigh/margin/paddingt: 0px; opacity:0; pointer-event:none; finally comes to an end
Also tabIndex="-1" and overflow: hidden
@@nitsanbh Yes, this one too.
Today is a good day! I felt it in my bones when I woke up this morning!
I've been waiting for this for YEARS lol so happy about this!
Jebus, Web Dev has gotten so easy these days!
SO glad we've got all these Frameworks that overcomplicate matters again
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.
@@paxdriveras someone starting coding / programming I agree, of course the more I do it gets easier but it should be more simplified imo
But we still cant transition to height auto...
There's an upcoming CSS value which will allow that -. height: calc-size(auto);, for example. Under development in Chrome, I believe.
unfortunately :(
but we can do a css only solution with grid :)
The amount of animation that are going to be made in the next 2 hours by me is going to be ungodly
đ đ
Allways great Videos you make! Happy to have youđ
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!
Looking forward to playing with this tomorrow
Very glad I watched to the end. That last bit of information will be very useful.
I truly appreciate your videos. They've helped me so much! â€
Thank you so much. I needed to do this today! I really appreciate you taking the time to cover the details and the caveats.
Thank you so much css devs, really needed this so bad. Had to use settimout and it was killing me everytime I wrote it
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
@@graysonpeddie that's plane wierd. Static websites are a thing of the past
@@heyyounotyouyou3761nothing wrong with static websites đ
Great news. I was waiting for this and I have a few drop-down elements with display none :)
this looks clean af to use, thx a lot Kevin ! Can't wait for it be better supported
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.
Crazy timing. I legit just found this two days ago for changing content visibility.
My first video was on 223k, now looks how much it grows. Because of you life is becoming easier and easier thank you.
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!
You just made my day, thx!! Finally
THIS IS THE BIGGEST NEWS IN CSS EVER!!! đČ I'm still shaking! can't believe this is real! thank you so much đđ
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 :-)
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 đ.
Great explanation, and very helpful as always. Thank you!
yaaaaaay now this and page transition , anchor position , container query we will be happy
The way Kevin explains complex concepts â€â€â€
Finally Maahn đđ đș
Oh gosh! Thanks, finally!
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. đ
Holy hell, thank you so much for this
I instantly know some of my sites that could use this and where it would make things 100% easier! đ
Love your Content, Thank you.
Wow that is so powerfull and will make things alot easier
Watching the Can I Use part all of a sudden reminded me of having to have a work around for border radius lol.
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.
What a time to be alive âš
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.
Finally that's really useful
Are you sure `transition-property: opacity display;` is working? Values shoud be comma separated
thanks, this information is very useful
Thank you css daddy đ
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.
Great video, as usual.
I think in transition-property each property needs to be separated by a coma!
transition-property: display, opacity, overlay;
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.
About flippin' time!
I can't tell how much I need it. Must needed to animate modal.
Miracles do happen đź
transition-property is officially supposed to be a comma-separated list, that's why the devtools were saying it's wrong.
Whoooa, bought in framer motion to achieve this for a big project before.
So glad to see this, But I am wondering how can I use in a faq using details & summary, Thank you so much Kevin.
You can use pointer-events:none on overlaying invisible modal and transition from there
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
Thanks!
Thank you!
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 :).
Now I know how framer motion works. Seems like I can get a lot more control doing in this way though.
Now we need a transition between justify/align content/items start/center/end.
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".
Thanks for this introduction! Although my old head is already pretty full with all the commands and rules... not only for CSS đ€
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.
thats awesome.
finally!!!!!!!!!!!!
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;
}
}
}
Finallyyyy
Thanks
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.
Key frames are also global so be careful what you call them to prevent accidental overrides.
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.
I've never clicked on a thumbnail so fast
Nice they starting to add stuff like this but I wouldn't implement it yet for compatibility stuff.
tnx a lot
Ayooo finally
Claude Opus just did this for me to create luminous slide up price cards last week
Getting ready for a bunch of fade in sites now
đâ€awesomeđâ€đ
Could you please create one video explaining full Tailwind CSS and also comparison of CSS with Tailwind CSS???
I hate having to wait for new features like this hahaha
Really wish legacy code bases could use this and modal/pop-up from the newer HTML stuff.
starting-style... Hopefully Firefox will support that in the future. Firefox seems already behind compared to Chromium-based browsers...
At 13:10, can somebody tell me why translate is animating even though we are only specifying transition-property display and opacity?
Edit: it looks like transition-property takes a comma separated list, and has an initial value of 'all'
@@tim-pn2fq I was wondering the same. Thanks for digging this up. :)
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!
Dialog with transition, good. but you forgot to show us button onclick method by the way đ
Great video as always! Curious as to why the translate: 0 -25vh; animates without being specified as a transition-property?
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
Can you make a roadmap of your videos/playlist to learn CSS?
Super cool! How does this affect accessibility? đ
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.
Big fan â€â€â€
Will it work in this case?
dialog {
...
&[open] {
...
&::backdrop { ... }
@starting-style { /* dialog starting styles */ }
@starting-style &::backdrop { /* dialog backdrop styles */ }
}
&::backdrop { ... }
}
My best teacher đ„đ€©đ„ł
If they fix margin-top my bucket list will be complete
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.
ah yes, "yes", my favorite animation type
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.
Nice to have a simple version of fromâŠto like in the animation key frame syntax though with âstarting-styleâ!
So wouldn't you have been able to add a nested &::backdrop within the previously set @starting-style?
Hmmm đ€ never thought this would be added lol
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 đ
Please, how to combine this technique with your solution for accordions made using grid-layouts and transitioning from 0fr to 1fr?