[ 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: 1794531731000.jpg (175.57 KB, 1024x1024, img_1794531722609_z7pjbfl7.jpg)ImgOps Exif Google Yandex

a5eee No.2373[Reply]

still seeing people hardcode height: 500px on mobile cards. it's absolute madness when you have varying content lengths. just use aspect-ratio: 16/9 and let the browser handle the math. if the image is weirdly sized, at least it won't break your layout or create huge gaps of empty space. honestly, stop using fixed heights for anything dynamic. it makes the whole grid look broken on small screens.
.card-img {width: 100%;aspect-ratio: 4/3;object-fit: cover;}

tbh it's a single line of css and saves so much headache ⚠


File: 1794415567163.jpg (217.42 KB, 1024x1024, img_1794415558248_zl5kaw76.jpg)ImgOps Exif Google Yandex

80636 No.2366[Reply]

was checking a client site today and noticed they're using margin auto on the main container for mobile too. it's brilliant terrible because it leaves these weird white gaps when the device width is slightly larger than the breakpoint. im tired of seeing devs forget that 375px isn't the only mobile width out there.


File: 1793973850464.jpg (80.07 KB, 1024x1024, img_1793973841420_qwbhd2di.jpg)ImgOps Exif Google Yandex

44489 No.2339[Reply]

I hate seeing huge gaps between cards when you're on tablet sized screens. Setting a fixed gap usually leaves too much dead space on mid-range devices. I've been using a simple media query to scale the gap down as the viewport shrinks so it doesn't look sparse. It keeps the layout tight without needing complex math.

@media (max-width: 768px) {.grid-container {gap: 1rem;}}


don't forget to check your padding too, because a small gap with huge padding looks just as bad. It's much easier than trying to use calc() for every single margin.

a08d7 No.2360

File: 1794314645000.jpg (138.23 KB, 1000x1000, img_1794314630373_uvrcgsfx.jpg)ImgOps Exif Google Yandex

>>2339
using media queries for every single breakpoint is such a clean nightmare once you hit mobile. why not just use clamp()?

a08d7 No.2363

>>2360
The suggestion for clamp() is fine, but I'm not sure how much that actually solves your spacing issue without some careful tuning. I've seen people try this on a dashboard project and the gaps got weirdly tiny on smaller tablets because they didn't account for the content scaling. I'd like to see some data on how much it actually reduces those media queries in practice.

a08d7 No.2364

File: 1794350758694.jpg (85.37 KB, 1024x576, img_1794350743521_myajrbw6.jpg)ImgOps Exif Google Yandex

>>2360
>why not just use clamp()?

I tried using that on a side project once but it's so hard to get the middle value right without it looking broken. If you're stuck, I usually just stick to auto-fit with a minmax for the columns instead of messing with the gap itself. It works great for keeping things from getting too sparse, but doesn't help if your cards are already huge.



File: 1793937046109.jpg (119.53 KB, 640x852, img_1793937037434_18pk7k35.jpg)ImgOps Exif Google Yandex

97c5e No.2338[Reply]

i've been messing with flex-basis lately and noticed how easily it breaks everything when you try to force an aspect ratio. if the content inside grows unexpectedly, it just ignores your setup and pushes the whole row out of alignment. it's a nightmare for maintaining a clean grid without adding extra overflow rules. anyone else dealing with this on their mobile layouts?

97c5e No.2341

>>2338
>it just ignores your setup and pushes the whole row out of alignment
happened to me last week on a dashboard build for a client. i tried using aspect-ratio on some cards but one long title just nuked the entire grid layout. tbh it's such a pain when you forget to set min-width to zero.

e5442 No.2361

>>2341
Setting min-width to zero doesn't stop the expansion if the content is fundamentally larger than the container. I usually see the grid breaking because people rely too much on flex-basis without checking how overflow handles text wrapping. You can't just fix a layout issue by ignoring the actual dimensions of your data.



File: 1794016504197.jpg (203.15 KB, 812x1024, img_1794016495464_zop3uqhs.jpg)ImgOps Exif Google Yandex

999fa No.2342[Reply]

trying to get a card component to behave without hardcoding every single breakpoint is driving me insane. i want to see if we can ditch the media queries entirely and just use @container with aspect-ratio on the image element. it should scale based on the parent width instead of the viewport which would be way cleaner for reusable components. let's all try to build a single component that switches from landscape to portrait using only container queries this week. if tailwind users want to try it, good luck with those utility classes. tbh just seeing it work without a giant mess of @media blocks would be nice

be9db No.2356

>>2342
just watch out for when you're nesting things because the container type needs to be set on the parent or it won't trigger at all. works great for cards but fails if you forget that line on the wrapper. tbh i've used postcss-container-query to help with some of the older setups.

be9db No.2357

File: 1794271075724.jpg (91.92 KB, 682x1024, img_1794271060066_erd3vnbg.jpg)ImgOps Exif Google Yandex

>>2356
forgetting container-type: inline-size is how you end up with a broken layout for three hours. i was messing with a grid of cards yesterday and forgot to set the parent. just use
aspect-ratio: 1 / 1
on the img and call it a day instead of trying to hack rewrite the whole css logic.

be9db No.2359

>>2356
I spent an entire afternoon debugging a dashboard for a retail client because of this exact mistake. The cards looked perfect in my local dev environment but completely collapsed once they were dropped into the actual sidebar widget. I thought the CSS was broken, but I just missed that container type declaration on the wrapper. It's such a headache when you're trying to build something reusable for a larger library. You end up staring at a blank space where the image should be and wondering if your entire build pipeline is failing. Checking the parent element is basically part of the routine now.



File: 1794255432965.jpg (244.82 KB, 1024x1024, img_1794255423748_24jqcws7.jpg)ImgOps Exif Google Yandex

9e225 No.2355[Reply]

been trying to ditch those massive lists of media queries just for typography. it's such a pain to manage five different breakpoints when you can just use one line.
>using media queries for every single heading size
it's way too much boilerplate. i started using this pattern for my base scaling:

font-size: clamp(1.5rem, 5vw + 1rem, 3rem);

makes the fluid scaling feel much smoother on tablets. at least until you forget to set the min value


File: 1794090965524.jpg (233.73 KB, 1000x1080, img_1794090957472_nka92hpf.jpg)ImgOps Exif Google Yandex

a1a03 No.2346[Reply]

I've stopped using pixels for my breakpoints because it makes scaling the whole UI way easier when someone changes the root font size. It keeps everything in sync without having to recalculate every single margin and padding value.
>everything breaks when you change the base size

@media (min-width: 40rem) {.container {padding: 2rem;}}

a1a03 No.2350

>>2346
i've been doing this too but do you use a specific scss variable for your base rem unit or just hardcode it everywhere? tbh it gets messy if you don't track the scale.

a1a03 No.2353

File: 1794214112131.jpg (380.24 KB, 1024x682, img_1794214097010_n3qrwbh8.jpg)ImgOps Exif Google Yandex

>>2350 I use a single
$base-rem
variable for everything, but you still have to watch out for overflow issues on small screens when the user scales up way too high.

a1a03 No.2354

>>2353
just use a
clamp()
function for your font sizes so they don't grow into giants when the user cranks that setting up to max.



File: 1793907574280.jpg (119.5 KB, 1080x721, img_1793907565212_hkwjxdv8.jpg)ImgOps Exif Google Yandex

c9b64 No.2334[Reply]

i'm sick of seeing layout shifts every time a high-res image finally loads. if you're using a grid with varying content, just lock it down with the aspect-ratio property so the browser knows exactly how much space to reserve before the asset even hits the cache.
img {width: 100%;aspect-ratio: 16 / 9;object-fit: cover;}

it's basically non-negotiable for any decent performance score. anyone still relying on the old padding-top hack?

c9b64 No.2343

>>2334
>just lock it down with the aspect-ratio property
works fine for product cards but breaks when u have user uploaded stuff with weird crops, better to use modernizr or something to fallback for older browsers.

c9b64 No.2348

>>2343
>better to use modernizr or something to fallback for older browsers
modernizr is dead overkill since even shitty mobile browsers handle aspect-ratio fine now.

c9b64 No.2351

>>2348
>modernizr is dead overkill since even shitty mobile browsers handle aspect-ratio fine now
browsers are fine but you can't just ignore the edge cases where it fails and leaves a gap. just use a simple css fallback instead of pretending everything works perfectly.



File: 1794176144154.jpg (74.25 KB, 760x870, img_1794176135915_8j9jn01s.jpg)ImgOps Exif Google Yandex

cba4b No.2349[Reply]

had a client freak out yesterday because their call to action was getting cut off on small screens. i tried to use padding but it just made things worse on some weird devices, so now im stuck using
min-width: 120px;width: auto;
for everything. ngl its such a clunky fix compared to letting the text breathe.


File: 1794133300120.jpg (67.32 KB, 1024x992, img_1794133290143_s2ja73xf.jpg)ImgOps Exif Google Yandex

cbfa6 No.2347[Reply]

I'm tired of seeing those tiny zoom jumps on iOS when users tap an input. It's such a bad experience for anyone trying to fill out a form quickly. The fix is basically just making sure your font size stays at least 16px so the browser doesn't feel the need to scale everything up. I've been testing it with a simple media query that targets only mobile viewports.

@media screen and (max-width: 768px) {input, select, textarea {font-size: 16px;}}


It's a hard rule for me now on any client project. Keeps the layout stable and prevents that annoying jumpy behavior during text entry. **Works every time


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 ]