tubeshowcase●1,072,070 videosβ™‘ My collection 0
← Learn to Code

Learn to Code16:20

A CSS Trick to select a specific row with Grid auto-fit/fill

Kevin Powell β†—

From the creator

Looking to step up your CSS Game? Check out https://cssdemystified.com πŸ”— Links βœ… Code for last row only: https://codepen.io/kevinpowell/pen/ogjwxyv/19639a71b6ff26e1bf87738fa6db12d5 βœ… Code for first two rows only: https://codepen.io/kevinpowell/pen/vENZGvG/14a4bdacb2fa79bbdd9cd1e400b57097 βœ… Code for 2nd row only: https://codepen.io/kevinpowell/pen/YPyQqMq/990300b888e8aec0d77d520d5948ddb5 βœ… Keith’s article: https://keithclark.co.uk/articles/targeting-first-and-last-rows-in-css-grid-layouts/ βœ… Temani’s version with no container queries: https://codepen.io/t_afif/pen/QwbZKPB?editors=1100 βœ‰ Keep up to date with everything I'm up to https://www.kevinpowell.co/newsletter πŸ’¬ Come hang out with other devs in my Discord Community https://discord.gg/nTYCvrK ⭐ Are you a beginner? HTML & CSS for absolute beginners is for you: https://learn.kevinpowell.co πŸŽ“ Start writing CSS with confidence with CSS Demystified: [https://cssdemystified.com](https://cssdemystified.com/) πŸš€ Already mastered CSS? Check out my advanced course, Beyond CSS: https://www.beyondcss.dev/ ⌚ Timestamps 00:00 - Introduction 00:45 - Requirements for this to work 01:45 - Setting up the first container query 03:00 - Getting the first two rows 05:10 - Getting only the second row 07:00 - Selecting the last row 13:44 - Using new CSS features so we don’t need container queries #css --- Help support my channel πŸ‘¨β€πŸŽ“ Get a course: https://www.kevinpowell.co/courses πŸ‘• Buy a shirt: https://cottonbureau.com/people/kevin-powel

Published 2025-08-13 Β· Watch on YouTube β†—
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code