Display none => block transition example

Anyone able to post a super simple demo of transitioning between display: none and display: block with the new discrete transition stuff? I've been messing about with it but can't seem to get anything working. Thanks
20 Replies
ἔρως
ἔρως6d ago
kevin should have a video about it, from last year
rctneil
rctneilOP6d ago
I've looked for videos, but just looking for a small demo codepen. My current code is: .memory-transcription { width: 100%; display: none; transition: all 0.25s; transition-behavior: allow-discrete; &.visible { display: block; } }
ἔρως
ἔρως6d ago
you didnt add a timing function, you are transitioning everything and you are using linear easing so, what will happen is that EVERYTHING will transition for 0.25s, then it should show
rctneil
rctneilOP6d ago
Ok, so I updated it to this and it still makes no difference: .memory-transcription { width: 100%; display: none; transition: display 0.25s ease-in-out; transition-behavior: allow-discrete; &.visible { display: block; } }
ἔρως
ἔρως6d ago
does it show? can you make an example in codepen or jsfiddle?
rctneil
rctneilOP6d ago
It shows and hides, but doesn't transition
ἔρως
ἔρως6d ago
that is the transition try setting the animation time to 5 seconds and it should take 5 seconds to show
rctneil
rctneilOP6d ago
It makes no difference
ἔρως
ἔρως6d ago
then can you make the example, please?
rctneil
rctneilOP6d ago
I am creating one as we speak Hang fire
rctneil
rctneilOP6d ago
Ok, it does seem to be doing something, although it's not transitioning smoothly
ἔρως
ἔρως6d ago
it wont ever it's a discrete property it goes from none to block there is no half-display either it displays or not
rctneil
rctneilOP6d ago
I thought the whole point of allow-discrete was to transition those though?
ἔρως
ἔρως6d ago
yes, and they are transitioning but there is nothing between display: block and none it jumps from none to block what you can do is to set display block and then transition the opacity and height, from 0 to auto the opacity from 0 to 1
rctneil
rctneilOP6d ago
Ok. Thankyou
ἔρως
ἔρως6d ago
you might want to play with animations instead like, swapping a class or an attribute and using an animation for it
althepal78
althepal786d ago
you might want to use it as opacity:0; there is another way you can make it not take up the space. but if you have it taken up the space in that way it wont change the layout of the page
clevermissfox
clevermissfox6d ago
CSS Weekly
YouTube
Animate to "height: auto;" & "display: none;" Using CSS Transitions
Find out how to easily transition from “height: 0;” to “height: auto;” and “display: none;” to “display: block;” without any hacks, tricks, or JavaScript, using only new CSS features: calc-size() function, transition-behavior property and @starting-style at-rule. UPDATE: The calc-size() function no longer supports a single argument; it works on...
Kevin Powell
YouTube
We can now transition to and from display: none
Start writing CSS with confidence 👉 https://cssdemystified.com/?utm_campaign=general&utm_source=youtube&utm_medium=transitiondisplay 🔗 Links ✅ Great article from Chrome for Developers blog on this : https://developer.chrome.com/blog/entry-exit-animations ✅ Open Web Docs: https://openwebdocs.org/ ⌚ Timestamps 00:00 - Introduction 00:40 - Using ...
clevermissfox
clevermissfox6d ago
KPow videos usually have a linked codepen in description

Did you find this page helpful?