[ 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: 1792602456564.jpg (113.03 KB, 1024x1024, img_1792602448104_nl4dbu7s.jpg)ImgOps Exif Google Yandex

9fd95 No.2262

I've been trying to stick to rems for everything lately but it's making my component margins feel totally disconnected from the local text size. If I change a heading to be larger, the spacing around it stays tiny because rem ignores the parent's font scaling. Using em for margins in cards works way better since the whitespace scales with the content itself. It's much more predictable when you're nesting elements.

.card {font-size: 1.25rem;margin-bottom: 1em;}

>rem is always better for consistency

That logic falls apart once you start building complex nested components that need to scale together. Stick to em for anything related to padding or margin inside a component's internal layout.

9fd95 No.2278

>>2262
>Stick to em for anything related to padding or margin inside a component's internal layout.

Using em everywhere makes it way too easy to accidentally break your whole layout just by changing one font size in a deep child element. **It's a nightmare to debug

9fd95 No.2285

File: 1792975866069.jpg (332.15 KB, 1024x1024, img_1792975851300_u62zucsy.jpg)ImgOps Exif Google Yandex

>>2278
>It's a nightmare to debug

I ran into this last week when I tried to use em for a button icon. I bumped up the font size on a wrapper and suddenly the icon was huge and pushing everything out of alignment. It works if you keep your component scope super tight, but it definitely gets messy once you have multiple layers of nesting. I ended up just reverting back to rems anyway

9fd95 No.2289

>>2285
>I ended up just reverting back to rems anyway

same thing happened with a sidebar widget. i used em for the padding and then bumped the icon size, and now the entire container is broken because the padding expanded way too far. it's fine if you use variables to lock things down but otherwise you're just asking for trouble.



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