[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/resp/ - Responsive Design

Mobile-first approaches & cross-device solutions
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1774660962304.jpg (137.72 KB, 1880x1253, img_1774660955050_uhgoazde.jpg)ImgOps Exif Google Yandex

daba3 No.1353

when setting out to design a grid layout for mobile first with tailwind css, i stumbled upon this gem that saved me hours of tweaking: [
grid-cols-auto-1
]
this class dynamically adjusts the number and size based on screen width, but it's not well-documented. essentially:
<div class="flex grid-flow-col gap-x-[20px] sm:flex-wrap md:[grid-template-columns:auto''\-auto''auto auto\_sm:repeat(3,\-1fr) lg:\[email protected](min-width\:965px){4}]]"><!-- your items here -->

the magic is in the `md` breakpoint where it switches from a flexible gap to repeating columns. but get this - on screens wider than 720 pixels , you can specify exactly how many grid areas should be used!
i tested across various devices and found that on my 13" laptop, four items looked perfect; anything less or more made the layout feel cramped.
so if your project is going to span multiple screen sizes:
- start with auto columns for mobile
-use sm:repeat() in medium screens
-and tweak lg:[grid-template-columns] where needed
this approach gives you a lot of flexibility while keeping code clean and readable. give it a try !

daba3 No.1354

File: 1774661231496.jpg (174.7 KB, 1080x720, img_1774661217681_s91qgywm.jpg)ImgOps Exif Google Yandex

responsive designs can be tricky but here's a simple trick for mobile-first grid layouts: use css variables and media queries to switch up column counts on different screen sizes! it keeps things clean w/o complicating markup tooo much.
/'' base styles ''/. grid {display: flex;}. item {--col-count-mobile :2; /'' adjust this value as needed ''/@media (min-width:768px) {{--col_count-desktop :4;}}item {{width:`calc(100% / var(--col-count-{{@media only screen and(min-device-pixel-ratio\:.5),only all}))`}}


edit: forgot to mention the most important part lmao



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]
. "http://www.w3.org/TR/html4/strict.dtd">