Skip to content
0:00 / 0:00

#cssgrid#csstransitions#heightauto

The simple trick to transition from height 0 to auto with CSS

Kevin Powell

1M subscribers • 13 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Kevin Powell

Intermediate. Assumes working knowledge.

255K views3 years ago2 recommendations

Web developmentCSS and layout

Kevin Powell shows how to animate elements from height zero to auto using a CSS Grid transition trick.

Animating or transitioning to and from height auto is, well, not really possible (though it is being worked on!), but luckily, there is actually a solution using CSS Grid that’s really easy to implement! 🔗 Links ✅ Keith J. Grant’s article on this (also includes a flexbox solution): keithjgrant.com/posts/2023/04/transitioning-to-height-auto/ ✅ The first simple example: codepen.io/kevinpowell/pen/poxroGv ✅ The accordion: codepen.io/kevinpowell/pen/NWOgVga ⌚ Timestamps - Introduction - The setup - The transition - It works with more content too - How I discovered this - Using it for an accordion #css -- Come hang out with other dev's in my Discord Community 💬 discord.gg/nTYCvrK Keep up to date with everything I'm up to ✉ kevinpowell.co/newsletter Come hang out with me live every Monday on Twitch! 📺 twitch.tv/kevinpowellcss --- Help support my channel 👨‍🎓 Get a course: kevinpowell.co/courses 👕 Buy a shirt: teespring.com/stores/making-the-internet-awesome 💖 Support me on Patreon: patreon.com/kevinpowell --- My editor: VS Code - code.visualstudio.com/ --- I'm on some other places on the internet too! If you'd like a behind the scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter. Twitter: twitter.com/KevinJPowell Codepen: codepen.io/kevinpowell/ Github: github.com/kevin-powell --- And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Why it's here

2 people recommend this

What people say. Recommended as a clever CSS Grid workaround for animating dropdowns and accordions from height zero to auto.

u/ElBombin r/Frontend • Recommends

On “How to make animated dropdown without using fixed height value?”

This is a slightly hacky way of doing it link to this video This is a better way but it doesn’t have full browser support yet link to this video

u/ProspectBleakin r/Frontend • Recommends

On “How to make animated dropdown without using fixed height value?”

Maybe this will help, different approach though [video