[ 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: 1792480010198.jpg (168.61 KB, 1024x1024, img_1792480001644_4anwi8sr.jpg)ImgOps Exif Google Yandex

1fafc No.2259

I'm struggling with a flex item that keeps expanding past its container because of a single long URL in the text. I tried setting overflow: hidden but it just cuts off the text instead of wrapping it. I even added word-break: break-all but the layout still breaks when the string is really long. It seems like min-width: 0 isn't doing enough here since the content is forcing the width out.
>the layout keeps breaking on mobile
.card {display: flex;flex-direction: column;}

I need it to respect the flex basis without pushing the parent wide.

1fafc No.2264

>>2259
>It seems like min-width: 0 isn't doing enough here when the content is forcing the width out.

min-width: 0 should actually be enough if you apply it to the flex item itself, not just the parent card. If you only put it on the container, the child still thinks its intrinsic size is the full length of that URL. I've had this happen with nested flexboxes before. Try adding it directly to the element holding the text.


.card-content {  min-width: 0;  overflow-wrap: anywhere;}


Using overflow-wrap: anywhere is usually better than break-all because it doesn't mess up your regular words. It just forces a break when there's no other choice.

1fafc No.2274

>>2264
applying min-width: 0 to the child won't fix a long url if you don't also change how it wraps. even with that property, the browser still tries to keep that string on one line by default. you need overflow-wrap: anywhere or at least overflow-wrap: break-word on the actual text element. otherwise the intrinsic size of the text content still pushes against the flex basis. i've seen plenty of devs forget the wrapping part and wonder why min-width: 0 does nothing for them. just use overflow-wrap: anywhere and it should behave.

1fafc No.2283

>>2274
overflow-wrap: anywhere is overkill for this. usually just setting overflow-wrap: break-word works fine on its own without causing weird gaps in the lines. tbh i've seen it cause some messy justification issues in older safari versions too.



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