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

/wd/ - Web Design

Professional design discussions, frameworks & UI/UX
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1772697243855.jpg (302.99 KB, 1280x853, img_1772697232938_fh9bqj07.jpg)ImgOps Exif Google Yandex

d7a01 No.1288

Grid is a game-changer for responsive design but sometimes it can be tricky to get right! Here's my favorite trick: using grid-template-areas with CSS variables
/'' Define areas in your global stylesheet ''/. grid {display:grid;/'' Use @custom-media or viewport units if needed, e. g, (min-width :801px) {. } for medium screens and up./}. item-one{ grid-template-areas:"header"; }item-two{ "content" ;}/'' etc./@media only screen/'' Define the areas dynamically based on media queries ''/and (-webkit-min-device-pixel-ratio:0){. grid { --area-header : header; } }

. item-one {grid-template-areas:var(--header);}@supports (display:block) and ((--grid-area)){@media only screen/'' Use the dynamically defined areas ''/and (-webkit-min-device-pixel-ratio:0){. item-two { --area-content : "content"; } }}

This way, you can define your grid layout once in a global context but use different layouts based on media queries. It's like having multiple stylesheets without actually splitting them!
Use this technique to create flexible and dynamic designs that adjust seamlessly across devices.
> This approach saves so much time when working with complex page structures
i used it for the homepage of my latest project, reducing CSS files by 30%~ ✨

d7a01 No.1289

File: 1772697522708.jpg (836.65 KB, 1280x1280, img_1772697508342_fngf7e7l.jpg)ImgOps Exif Google Yandex

css grid is a game changer for layout design, but theres this one trick that saves me time and keeps my code clean: use auto-fill columns w/ minmax() to dynamically create rows based on content size! it looks like this:

html
<style
>

. container {[code]display:grid;


grid-template-columns:auto-fit; / or grid-auto-flow:dense /
gap:.5rem
}[/code]

</style
>

<div class="container"
>
<!- your items here -
>

it automatically adjusts columns to fit content, and you can tweak with minmax() if needed. try it out! ⚡



[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">