CKTIS / CSS
transition-behavior — transitions for discrete changes
transition-behavior determines whether CSS transitions can include discrete changes. The allow-discrete value permits a value to switch during a transition, but does not turn that switch into smooth interpolation.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate
Syntax
transition-behavior: [ normal | allow-discrete ]#;transition-behavior controls whether transitions start for discrete changes: changes that switch values instead of producing intermediate values. The initial normal excludes these transitions; allow-discrete permits them while still allowing interpolation of other properties. It does not enable animation of properties defined as not animatable. The property itself is neither inherited nor animatable.
Comma-separated values correspond to entries in transition-property. You must still select the property and configure suitable transition timing. An ordinary discrete change switches at 50% progress after the timing function is applied. display is exceptional: when transitioning to none, the element remains visible until the end; when transitioning from none, the value switches at the start.
The example demonstrates exit only: opacity decreases over 1s, and display changes to none at the end. Placing transition-behavior after the transition shorthand prevents that shorthand from resetting it. allow-discrete alone does not ensure an entry transition from display: none; @starting-style may be needed to establish the starting style.
Examples
<!doctype html>
<meta charset="utf-8">
<title>transition-behavior</title>
<style>
#panel {
display: block;
opacity: 1;
padding: 1rem;
background: lightblue;
transition: opacity 1s linear, display 1s linear;
transition-behavior: normal, allow-discrete;
}
#panel.closed {
opacity: 0;
display: none;
}
</style>
<button type="button" onclick="document.getElementById('panel').classList.add('closed')">Close</button>
<div id="panel">Panel</div>Result
After Close is activated, Panel fades out over 1 second while display remains block, then display becomes none. Further activations do not change the state.
The example code and its stated result were verified in an isolated environment.