10303 shaares
289 private links
289 private links
interpolate-size
is a way to animate height: auto
or width
. It is only supported in Chrome for now.
A quick example:
@supports (interpolate-size: allow-keywords) {
:root {
interpolate-size: allow-keywords;
}
details {
transition: height 0.5s ease;
height: 2.5rem;
&[open] {
height: auto;
overflow: clip;
}
}
}
A more generic one:
:root {
interpolate-size: allow-keywords;
}
details {
--calculated-details-padding: var(--details-padding, 1em);
transition: height var(--details-transition-speed, 150ms) linear;
height: calc(1lh + (var(--calculated-details-padding) * 2));
padding: var(--calculated-details-padding);
background: var(--details-bg, white);
color: var(--details-color, currentColor);
}
details[open] {
height: auto;
overflow: clip;
}