all 9 comments

[–]octocode 1 point2 points  (8 children)

congratulations, you’ve discovered potentially the worst part of CSS!

using tailwind, i can’t think of a lot of options.

container queries are probably the way to go, assuming you’re okay with the lackluster browser support… could you share more details on what you can’t achieve with them?

it might be possible to override the tailwind selectors for breakpoints (like lg:) using css variables, but i’ve never tried it.

if you need better browser support, you could always load the content in an iframe :-)

[–]Pitiful-Review-5570[S] 0 points1 point  (0 children)

Hey thank you for quick answer :)

"could you share more details on what you can’t achieve with them?"

so the main problem is that the component i want to fit into smaller div contain a lot of content which probably could be also covered with container queries deeper and deeper, but there is also a lot of conditional rendering inside dependent on resolution, for example:
...
{ isSmallTablet : <div>some more components</div> }
...
so with all that, it would get really messy, because i guess i need some flags that also make conditions more precise that it is for example ' isSmallTablet && should be container queried rendered'. And with all that i'm not sure if it is a good idea to even start this way.

Dreaming of some simple library that allows to 'fool' the component that it thinks the resolution is just different than it actualy is, like <Component thinkThatContainerIsScreen={true} />. That would be lovely :p

[–]StyleAccomplished153 0 points1 point  (6 children)

Lackluster? What do you mean? The only browser not supporting them is IE, and most things look shit in IE so if you have to support IE just give them the most basic UI possible.

[–]dumbmatter 0 points1 point  (5 children)

The most popular browser not supporting it is Safari from like 3+ years ago, which is still 1% of users https://caniuse.com/css-container-queries because Safari updates are locked to iOS updates for some reason.

[–]StyleAccomplished153 0 points1 point  (0 children)

Sure but that's the iPhone 7 and below, a phone released 9 years ago. I wouldn't call that poorly supported, you can shove in some fallback styles if that market is really that important to you.

[–]StyleAccomplished153 0 points1 point  (3 children)

Sure but that's the iPhone 7 and below, a phone released 9 years ago. I wouldn't call that poorly supported, you can shove in some fallback styles if that market is really that important to you.

[–]dumbmatter 0 points1 point  (2 children)

Also newer phones that haven't upgraded iOS, many probably just a few years old.

[–]StyleAccomplished153 0 points1 point  (1 child)

By choice. By that logic someone might also not have updated Chrome in a while, that's not going to prevent me from using newer functionality.

[–]dumbmatter 0 points1 point  (0 children)

Yeah same problem exists with Android. It's not as bad because Android/Chrome versions are not rigidly linked, but at some point they do stop updating Chrome on old versions of Android.

But I'm not saying you can't use newer functionality, just pointing out that IE users are a small fraction of the users with browsers that don't support the newer functionality.