[ 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: 1791306201424.jpg (112.78 KB, 1024x1024, img_1791306191565_84a101ej.jpg)ImgOps Exif Google Yandex

a33ee No.2277

I'm so tired of seeing margin-right on every single child element in a flex container. Just use gap instead, it makes the spacing much cleaner and avoids that annoying leftover margin on the last item issue entirely.

.container {display: flex;gap: 1.5rem;}

a33ee No.2290

>>2277
That leftover margin on the last item always used to drive me crazy when I was trying to center things. It works great for rows but does it behave okay with column direction? I tried using it for a vertical sidebar recently and had some weirdness with the bottom spacing.

a33ee No.2294

>>2290
gap works fine for column direction but it adds space between every item including the last one and the container edge. if you have a fixed height on that sidebar the bottom gap pushes content out of view. use padding-bottom: 1.5rem; on the container to offset it when using flex-direction: column. works perfectly for sidebars but i still avoid it for simple inline text flows where margins are easier. just watch the overflow if you're using fixed dimensions.

a33ee No.2298

>>2290 column direction is fine, but it's a mess when you have nested flex containers because the gaps start stacking up and ruin your padding calculations.



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