
Browsers use dictionaries to figure out when hyphenations need to kick in, so tell your browser what language your content is in.īrowser support for hyphens has improved since Florian’s talk, so this is a viable option. Incorrect hyphenation makes the text really difficult to read. Often, the content is not even written by you, can you even coordinate all your content writers to use in their writing? What if you’re using markdown? Then your content will end up being littered with a weird mix of HTML and markdown? Tricky, tricky.īrowsers can do automatic hyphenation, but you must have the lang attribute set correctly. This approach only makes sense if you have absolute control over the content and markup. For visible hyphens use U+2010 or &dash, while for invisible hyphens, use U+00AD or . What about hyphenation? Is that even a thing in CSS? Well, the answer is kinda sort of? If you haven’t watched the video linked above yet, there’s a section on hyphenation at the 15.16 minute mark which I’m linking here so you don’t have to scrub: The hyphens property.īy default, hyphenation is set to manual, which means that you are responsible for the hyphens themselves. Grid-template-columns: repeat( auto -fit, minmax( 180 px, 1fr)) Let the browser do itįirst option, you could consider ditching the min-width on the item, then apply that value into the minmax() function for your column width, and let the browser figure out how many columns you need instead. The problem is occurring on a 3 column grid where items have a min-width: 180px applied. Say you’re very firm on not having the item shrink beyond the designated width.

Once you’ve managed to locate said element with an unshrinkable width, you need to ask yourself if you REALLY need that minimum width on the item itself, or is it still okay to have some shrinkage beyond that set width. Make the viewport narrower than is reasonable so it’s more obvious. If you have a really long page and can’t really figure out what the offending element is, try scrolling all the way to the right and scroll from the top to bottom and see if you can find any bits sticking out. Well, since you already have those Devtools open, that’s already starting on the solution, eh? A common cause is having items in your layout that are fixed width or have some min-width value that ends up larger than your viewport width at that point in time. Also, according to iOS resolution, even the iPhone 13 has a logical width of 390px, so dock those Devtools, I say.
Overflow css horizontal scroll pro#
Or you could, I don’t know, ACTUALLY test on a narrow mobile device?įor what it’s worth, my phone is a Realme 3 Pro which is still happily chugging along, and it has a viewport width of 360px. So the tip here is, dock your Devtools for testing narrow viewports. If you dock your Devtools to the left or right of your viewport, then you can shrink the viewport down to near 0px if you really wanted to. That is, if you have your Devtools in a separate window.

The last I checked, Firefox stops at 435px, Chrome stops at 500px and Safari stops at 559px. But did you test it at all?īut first, let’s go with the broad strokes situation of simply not testing at a narrow enough viewport.

This is because there will inevitably be some edge cases where a trade-off needs to be made on whether to just let things be. Anyway, we thought it was worth a discussion, from why this phenomenon exists to how we can do our best to avoid it.Īs you can see, I have chosen the reasonably “loose” phrase “do our best”. Which is very different from intentional horizontal scrolling on mobile. My good friend, Wei, has a pet peeve: unintended horizontal over-scrolling on mobile.
