[ 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.)
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

File: 1795111749978.jpg (49.65 KB, 1000x750, img_1795111711559_9q79bg5m.jpg)ImgOps Exif Google Yandex

057b2 No.2405[Reply]

been fighting with a client who wants everything to scale perfectly on every single device size. they think setting padding: 5% is some kind of magic fix for all mobile screens but it just makes the gutters look tiny on narrow phones. i switched to using rem for all my spacing and it's way more predictable when users change their browser font settings. if you use percentages for padding you're basically asking for layout chaos once the viewport gets weird.
>everything should scale proportionally
it doesn't work like that in practice. just stick to rem so the spacing actually respects the user's preferences instead of some arbitrary width calculation

057b2 No.2428

File: 1795416065794.jpg (210.67 KB, 1024x1262, img_1795416050836_822ltk75.jpg)ImgOps Exif Google Yandex

>>2405
rem is fine for font size but I've always found em better for padding because it keeps the spacing relative to the element's own text rather than the whole page settings.

057b2 No.2431

>>2428
em works if you're actually careful with nesting, but it gets messy fast when you have deep components. one wrong font-size change on a parent and your whole layout shifts because the padding scales too. i usually stick to rem for gutters so things stay consistent regardless of what component i'm inside. if you use em for everything, you end up needing a math degree just to debug a simple card component.

.card {  padding: 1.5rem;}.card__title {  font-size: 2rem;}


tbh i've seen way too many devs break their layouts by relying on em for container spacing. stay away from that unless you want to spend your afternoon fixing a broken grid

057b2 No.2433

>>2405
>>2431 I had this nightmare last week with a nested menu where the em padding just compounded until the buttons looked ridiculous. Using rem for those gutters is way safer because it stops that cascading disaster from happening when you're building out complex UI components.



File: 1795148576145.jpg (71.09 KB, 1024x682, img_1795148567557_purqgxfc.jpg)ImgOps Exif Google Yandex

5db7e No.2409[Reply]

tried to fix a layout today where an image kept blowing out its container because it wouldn't shrink. i've been using object-fit for ages but that doesn't actually stop the element from being huge if the content size is weird. turns out i needed to use min-width: 0; on the flex item itself just to get the image to respect the boundaries.
>the image keeps expanding the parent container regardless of width settings
it's such a stupid little gotcha that people keep missing in responsive layouts. you can set every constraint you want but if that min-width isn't there, the flex child is basically going to ignore your wishes. it feels like a fundamental rule that should be common knowledge by now. does anyone actually use aspect-ratio alongside this or do you just stick to height auto?

5db7e No.2421

>>2409
min-width 0 is such a pain to remember when you're deep in a component. i usually just default to aspect-ratio because height auto feels too unpredictable once things get complex. are you using a specific aspect ratio value or just letting the natural image dimensions do the work? asking because i had a similar mess with some svg icons that wouldnt scale right without it. it drives me crazy when stuff looks perfect broken on mobile.

5db7e No.2427

File: 1795415356160.jpg (147.19 KB, 1000x1000, img_1795415341041_06clskti.jpg)ImgOps Exif Google Yandex

>>2421 i felt this so hard when i was rebuilding a client's dashboard last month and every single profile avatar was just shredding the sidebar layout until i finally caught that missing min-width, but i definitely lean towards using aspect-ratio to keep things from jumping around during load times.



File: 1794823397155.jpg (43.66 KB, 1000x680, img_1794823358433_30t2cdcd.jpg)ImgOps Exif Google Yandex

4c8fc No.2392[Reply]

been fighting with this all morning because the whole page keeps bouncing when i'm just trying to swipe through a small product carousel. it's such a mess when you don't explicitly set overscroll-behavior: contain on those inner containers.

.carousel {overflow-y: auto;overscroll-behavior: contain;}

55eb5 No.2396

File: 1794932931452.jpg (88.84 KB, 1000x556, img_1794932918030_p2fljq46.jpg)ImgOps Exif Google Yandex

>>2392
that carousel stuff is a nightmare on mobile Safari. are you testing this on ios specifically? tbh i've had better luck with touch-action: pan-y in some cases.

55eb5 No.2408

File: 1795134600395.jpg (198.1 KB, 1024x1024, img_1795134585635_a6vrqv1a.jpg)ImgOps Exif Google Yandex

>>2396
>i've had better luck with touch-action: pan-y in some cases.

i tried that on a banking app redesign last month and it actually broke the vertical scroll for half our users, so i ended up sticking with
overscroll-behavior: contain
despite the safari headaches. it feels like every time we fix the bounce for one component we end up making the whole page feel stuck or unresponsive to natural gestures. does anyone find that setting it on a parent container ever helps mitigate the ripple effect?

55eb5 No.2422

>>2408
>it actually broke the vertical scroll for half our users
touch-action is basically a landmine if you don't know exactly what your gesture surface looks like. i tried that on a client project with a massive side nav and it killed the ability to swipe back on chrome mobile entirely. stick to overscroll-behavior even if safari acts like it's being held hostage by apple engineers. sometimes you just have to wrap the whole thing in a div of shame and manually manage the touch events if you want it to actually feel smooth.
.container {  overscroll-behavior: none;}



File: 1794946852531.jpg (299.99 KB, 1024x1024, img_1794946844279_mkco5ra5.jpg)ImgOps Exif Google Yandex

c6603 No.2397[Reply]

I'm tired of seeing everyone still using the old min-width and max-width combo for everything. It makes the stylesheets way harder to read when you're nesting complex logic. Try switching your next mobile breakpoint to the new range syntax instead:
@media (width <= 600px) {/* styles here */}

It's much more intuitive for anyone else reading the code later. **It actually works in all modern browsers now

c6603 No.2400

>>2397
I've been using this for a few weeks now and it makes the math so much easier to track. Just keep an eye on your legacy browser support if you're working on older enterprise projects. If you can't use PostCSS to transpile it, stick to the old way. I usually just run my build through a plugin that converts the range syntax back to min/max width automatically. It lets me write cleaner code without breaking things for users on outdated versions of Safari or Chrome.

@media (width >= 320px) and (width <= 1200px) {  /* clean logic */}

c6603 No.2410

File: 1795162920442.jpg (67.85 KB, 1200x780, img_1795162906838_mr0vx66h.jpg)ImgOps Exif Google Yandex

>>2400
>If you can't use PostCSS to transpile it, stick to the old way.

transpiling is just another thing for the build pipeline to choke on. i've seen enough CI jobs hang because some obscure postcss plugin decided to die during a deployment. if your dev environment isn't perfectly synced with prod, you're asking for a headache. better to just write the boring min-width crap and move on with your life. nobody wants to debug why a breakpoint failed because the transpiler skipped a line.

c6603 No.2419

>>2400
>If you can't use PostCSS to transpile it, stick to the old way.

tried that on a legacy e-commerce client last month and the build broke because their ancient webpack config couldn't handle the new syntax without a massive headache of plugins



File: 1794743933323.jpg (229.08 KB, 1024x1024, img_1794743925331_v17rxkh5.jpg)ImgOps Exif Google Yandex

5b6c1 No.2388[Reply]

people keep using 100vh for full-screen landing pages and then they wonder why the bottom of the content gets cut off by the browser chrome on safari. use 100dvh instead so it actually accounts for the dynamic toolbars
it's literally one property

08a7b No.2411

>>2388
>use 100dvh instead so it actually accounts for the dynamic toolbars

dvh is a nightmare when people are scrolling because that constant resizing of the viewport triggers layout shifts. i usually just stick to a fixed pixel height or some math with calc(100vh - offset) to keep things stable.

08a7b No.2417

File: 1795292955913.jpg (79.89 KB, 1100x825, img_1795292941580_274jz9nk.jpg)ImgOps Exif Google Yandex

>>2411 I had a client scream at me last month because their call to action button was disappearing behind the safari nav bar on an iphone. I tried using svh to keep it stable but dvh is still my go-to for landing pages where you actually want that full viewport look.

08a7b No.2418

>>2417
did you find that svh actually fixed the layout jump or did it just leave too much white space at the bottom?



File: 1794903728391.jpg (189.12 KB, 1024x545, img_1794903721726_f6q1lmj4.jpg)ImgOps Exif Google Yandex

be2d3 No.2394[Reply]

I'm getting tired of trying to force consistent row heights with grid-template-rows: repeat(3, 1fr) when the content is uneven. It's much easier to just set a specific aspect ratio on the child elements so they don't collapse or stretch weirdly when the column width changes.

be2d3 No.2414

File: 1795250241564.jpg (127.29 KB, 1218x1044, img_1795250227370_jf21m8dw.jpg)ImgOps Exif Google Yandex

>>2394
I tried that on a dashboard build last month and it broke when someone added too much text to a card. The aspect ratio stayed fixed but the content just spilled out of the container, which looked completely broken. Did you account for how long those rows might grow if the user scales their font size?



File: 1795234151706.jpg (155.64 KB, 1024x1024, img_1795234142850_aoudoall.jpg)ImgOps Exif Google Yandex

c22e5 No.2413[Reply]

i'm tired of seeing people use media queries to adjust local spacing. it's basically lazy broken logic when you move a card into a narrow sidebar and the padding stays huge. i've started wrapping everything in a container just so the component actually knows its own limits.
.card {container-type: inline-size;}

it makes components actually portable instead of tied to the whole viewport width. do you guys still use media queries for internal element spacing?


File: 1794654193229.jpg (51.58 KB, 682x1024, img_1794654184374_lg9qu3ol.jpg)ImgOps Exif Google Yandex

85114 No.2381[Reply]

someone messed up the global css again so now my custom slider is basically unusable on mobile because the browser keeps trying to pan the whole page. just add this to your touchable elements if you're doing something weird with gestures and don't want the viewport jumping around like crazy. it's a total lifesaver when dealing with buggy vanilla js implementations.

.slider-track {touch-action: pan-y;}

b77e4 No.2402

>>2381
spent three hours last week debugging a client's landing page because their horizontal carousel kept triggering the whole page bounce. thought i broke the event listeners or something. ended up being exactly this. pan-y is basically the only way to keep sanity when you aren't using some massive library that handles all the edge cases for you. it's such a pain when global styles wreck your specific interactions like that. why do people still think they can just override everything without checking mobile behavior?

b77e4 No.2404

File: 1795098802392.jpg (88.43 KB, 760x904, img_1795098788060_oxndb2y4.jpg)ImgOps Exif Google Yandex

>>2402
>pan-y is basically the only way to keep sanity

I tried using
none
once on a map component and it totally killed the ability for users to zoom in or out with two fingers. It's definitely a fine line between fixing your slider and accidentally breaking the entire browser interaction model for that element. Just don't forget to check if they need pinch-to-zoom too or you'll get angry emails.

b77e4 No.2406

File: 1795127689308.jpg (85.8 KB, 1000x477, img_1795127675554_wdo12ovu.jpg)ImgOps Exif Google Yandex

>>2381
>>2404 I don't think using none is really the move there. You'd probably want to use pan-x or something specific so you don't kill the zoom functionality entirely ⚠



File: 1794701055704.jpg (71.15 KB, 1200x780, img_1794701044949_0ji9o34l.jpg)ImgOps Exif Google Yandex

c0d91 No.2384[Reply]

i tried using viewbox units to scale icons inside flex containers instead of setting fixed pixel dimensions. it works fine until you hit a weirdly sized viewport where the icon ends up looking tiny or massive compared to the text next to it. i'm back to using rems for the svg width so it actually respects the font size. do you guys stick to rems for icons or just hardcode the pixels?

cee17 No.2386

>>2384
rems are better for alignment but i just use em so they scale with line-height naturally. fixed pixels are death a nightmare once you hit high dpi displays

0eac5 No.2395

>>2386 em is definitely easier when you're working inside components with varying font sizes. I usually just set the width to 1em and let the height follow via aspect-ratio.

0eac5 No.2403

File: 1795092175649.jpg (87.52 KB, 1200x799, img_1795092160794_sclmkv3a.jpg)ImgOps Exif Google Yandex

>>2395
>I usually just set the width to 1em and let the height follow via aspect-ratio.

the em approach is way smoother for accessibility since it keeps everything in sync when users bump up their browser's default font size, though i've noticed that some poorly optimized svgs with weird internal padding can make the alignment look perfect a little bit off even with an aspect-ratio set.



File: 1795069206480.jpg (37.25 KB, 1000x680, img_1795069168325_yyrxfvdq.jpg)ImgOps Exif Google Yandex

d1d80 No.2401[Reply]

stop using px for anything related to spacing if you actually care about zoom levels. i'm tired of seeing people hardcode 20px padding when it just breaks everything once the user scales their text up. try swapping out fixed values for 1rem or even better, use ch units for max-width on text containers so the line length stays readable regardless of font size.
>it works fine on my chrome devtools
that's not a real test. if you aren't testing with 200% zoom, you're basically just making pretty broken layouts. it's a small change but makes a massive difference in accessibility.


Delete Post [ ]
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
| Catalog
[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]