Picking a breakpoint for media queries can be a little tricky. Generic breakpoints sometimes donβt seem to do the job, and using specific device sizes is problematic because there are too many of them.
Thatβs why I like to go with more of a content-first approach, to a certain extent anyway. We donβt want to get too precise either, or we end up with way too many of them!
Container queries also change the game a little when it comes to breakpoints, opening up some new options and possibilities.
β
The ideal viewport doesnβt exist: https://viewports.fyi/
β
Piccalilli article that uses the container query viewport trick: https://piccalil.li/blog/reality-check-1-building-out-a-furniture-site-from-dribbble/
β
Code from first example: https://codepen.io/kevinpowell/pen/wBvmdor
β
Code from second example: https://codepen.io/kevinpowell/pen/WNVbbXZ/fef60d4f8a980bb59e4eed25fe69cfc0
β
Looking to improve your CSS skills? https://kevinpowell.co/courses
00:00 - Introduction
00:50 - Working with ranges
05:00 - You donβt need all those breakpoints
05:50 - Content-first breakpoint approach
07:00 - Donβt micromanage your breakpoints
07:50 - Approaching this with a real layout
13:50 - When container queries make more sense
19:45 - Container queries based on the size of the columns you want
22:12 - Another example of container queries being useful
β 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
π Already mastered CSS? Check out my advanced course, Beyond CSS: https://www.beyondcss.dev/
π¨βπ Get a course: https://www.kevinpowell.co/courses
π Buy a shirt: https://cottonbureau.com/people/kevin-powell
π Support me on Patreon: https://www.patreon.com/kevinpowell or through YT memberships: https://youtube.com/@KevinPowell/join
π§βπ» My editor: VS Code - https://code.visualstudio.com/
π My theme: One Dark Pro Var Night
π€ My font: Cascadia Code
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:
Bluesky: https://bsky.app/profile/kevinpowell.co
Codepen: https://codepen.io/kevinpowell/
Github: https://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!