How to set max-columns using auto-fit or auto-fill

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

Sign in to save videos and track what you’ve finished.

IntermediateUI17 min

About this video

Shows how to limit the number of columns CSS Grid creates with auto-fit or auto-fill by using calc() to set a maximum. It covers making the layout readable, stacking at smaller sizes, preventing overflow, and a newer CSS feature that improves the approach.

What you’ll learn

  • Cap the column count of an auto-fit grid using calc()
  • Make a responsive grid stack at smaller screen sizes
  • Prevent grid items from overflowing their container