Menu

CSS Transitions Skip display: none. transition-behavior Fixes That.
📰

CSS Transitions Skip display: none. transition-behavior Fixes That.

DEV Community: css·Parsa J·8 days ago
#txq29xAG
#devtocss#devto#dev#transition#display
Long article (1332 words) — no AI summary yet.
Reading 0:00
15s threshold

You build a dialog. You add transition: opacity 0.2s, transform 0.2s . You open it.

It just appears. No fade, no slide — a jump-cut, like someone spliced the film.

You check the transition is spelled right. It is. You check the element is actually changing opacity. It is — from 0 to 1 , exactly like you wrote it. So why does it still snap?

Because the element isn't only changing opacity. It's also going from display: none to display: block , and CSS has never known how to transition that.

The property transitions can't touch

display isn't a number, a color, or a length. You can interpolate opacity: 0 to opacity: 1 because the browser can compute every value in between — 0.3 , 0.7 , whatever the easing curve wants at that frame. There is no value "in between" none and block . An element is either laid out or it isn't.

Properties like this are discrete : display , content-visibility , overlay , visibility (sort of — more on that below).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.