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

/css/ - CSS Masters

Advanced styling, animations & modern CSS techniques
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1773502717138.jpg (106.57 KB, 1880x1252, img_1773502709608_5nd9zvo7.jpg)ImgOps Exif Google Yandex

be2d1 No.1314

If youre tired of fiddling with grid properties to get that perfect layout. try this trick!
I recently discovered a super simple way to ensure items align perfectly in both rows AND columns, regardless if the number is even or odd. its like magic!
heres how it works:
. container {display: flex;}. item:nth-child(odd) { /'' Aligns every other item ''/margin-right:auto;}/ For an extra push to align everything in columns too (20px is your mileage may vary):/@media(min-width :768px){. container> *{margin-bottom:.5rem;}}

This tiny bit of CSS ensures that items are perfectly spaced and aligned, even on smaller screens. its a lifesaver for responsive designs!
Give it a try next time youre working with grid layouts - especially those pesky odd-numbered item counts!
>Just remember to tweak the margin-bottom value as needed based on your design requirements.
Grid Magic is yours now ✨

be2d1 No.1315

File: 1773503025375.jpg (226.52 KB, 1880x1253, img_1773503010256_g0q5vj9v.jpg)ImgOps Exif Google Yandex

css grid has a nifty trick for creating responsive layouts that adapt to different screen sizes without media queries: use percentage-based gutters and column tracks

for example, if you have 3 columns with equal width in percentages:
grid-template-columns: repeat(4, [col_]1fr);

then define the gutter as a fraction of one track's size using `calc()`:

[col'']:nth-child(-n+2) ~ :not([col''{}) {grid-column-gap: calc((30px / (6 - var(--gutters))) *.5);}

set -gutters to the number you want, e. g,
--gutters=4
for three gutters

this setup keeps your layout fluid and responsive across devices ⬆



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