This CSS Trick Makes Impossible Animations Possible

preview_player
Показать описание

🌎 Find Me Here:

#Shorts
Рекомендации по теме
Комментарии
Автор

😭 this would have saved me 6 hours if only you’d released it 2 days ago 😂😫

GH-puxc
Автор

Found this trick from Kevin a few days ago, this is a great way to animate simple pop-ups and bigger nav blocks alike

blackpurple
Автор

U can use transform: scaleY(0); to transform: scale(1). And you might need to set the transform-origin to top

riwahoussari
Автор

now that's a solution i certainly was not expecting

backup_hdd
Автор

Something to note is that animating layout changes is expensive to browser perfomance because browser has to calculate layout and repaint

hanesmitter
Автор

Much struggle with this issue a lot....i used to transition using max-height...🍻🙌🏻🙌🏻

alokkothiyal
Автор

Css animation
- issue: unable to animate from height: 0-> height: auto
- solution: need a explicit height
— additional wrapper with row-template-rows: 0
— open row-template-rows: 1fr

use 1fr and overflow hidden

leebobtheblob
Автор

No one mentioned that it's usually a bad thing to animate layout prone properties. They cause layout shift and intensive calculations. What you want to do instead is animate using transform and opacity, as they happen after the layout calculations

whoeverseesthatbehappy
Автор

Clever. Ive been using max height for it because it can be animated

perfect.stealth
Автор

man this is amazing.... thought it'd be impossible to do animate unknown heights without scss and js involved. props 👏

ahmedn.
Автор

Working on a feature like this soon. Thanks

daxtron
Автор

it is like 13 years that i wanted to know something like that! thank you!

stefanoesu
Автор

That's neat you can do it in pure CSS now.

penry
Автор

use this idea for another video. you can go without wrapping, and also without having overflow hidden (you might want to add a scroll) since 'transform' can be animated,

.default_class {
// ur other style;
transform: scaleY(0);
transform-origin: top;
transition: .2s all ease-in-out;
}
.default_style.open {
transform: scaleY(1);
}

Though you might also wanna wrap it because transform usually break z-index, but you can control that with a parent div wrap

aminehl
Автор

We’re getting height: auto animations soon though! CSS working group is on a roll

nielskersic
Автор

we can use transform: scale and transform-origin: top

anasali-ytlg
Автор

Man I have been looking for a way to animate height without setting it for a while.. thanks alooot Kyle.. this is incredible...

royhyde
Автор

Just toggle from max-height: 0 to a large max-height. Works in most cases.

rehan_requiem
Автор

This is why i subscribe him, always new thing to learn

hamzahokkamahendra
Автор

Thanks.

I think this can be done be combining height: auto and max-height as well though?

Haven't tried it in a while, but I think that will work and be less trouble.

EivindFigenschauSkjellum