Thehorizontal overflowproblem

By Chen Hui Jing (@hj_chen) & Gao Wei (@wgao19)

Wei profile image Hui Jing profile image

Wiggling webpages 😤

My money don't jiggle jiggle…

How does a webpage wiggle? 🤔

This is not very pleasant

Did you even test on real devices?

Chart showing different Samsung screen sizes
Source: Does Samsung make too many phones and tablets?

Devtools can test is can test, but…

There's a minimum width on most browsers

Real device versus devtools simulator

  • Finger touches constitute coarse cursor, the real touches cannot be as fine as a mouse pointer in a desktop browser emulator
  • Certain behaviors only present on mobile devices
  • Performance considerations
  • Collapsing headers & layout when virtual keyboard activated causing content to overflow

Devtools with mobile Safari

Advanced settings on iOS for Safari
Must turn on Web Inspector
Advanced settings on macOS for Safari
Must turn on Develop menu

Devtools with mobile Chrome

Developer settings on Android for Chrome
Must turn on USB debugging
Devices settings on Chrome Devtools
Don't think you need to turn on anything extra

Devtools with mobile Firefox

Developer settings on Android for Chrome
I also dunno why kenot

How to find the offending element?

Some days easy, some days hard

If layout code gone wrong, then how?

Sometimes the grid items have either a fixed width or a min-width value applied.

a cute kitten a cute kitten a cute kitten a cute kitten a cute kitten a cute kitten a cute kitten a cute kitten a cute kitten

Consider adding breakpoints as required

Nobody said cannot use breakpoints
.grid {
  grid-template-columns: repeat(2, 1fr);
}

@media screen and (min-width: 30em) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

If word too long, then how?

Sometimes you have a really long word in the item that the browser won’t break. Watch Line breaking and related properties from CSS Text for in-depth explanation on line-breaking.

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

a cute kitten

Not a Hippopotamus, sometimes it's a URL like www.incomprehensibilities.com

Is hyphenation a thing?

For visible hyphens use U+2010 or ‐, while for invisible hyphens, use U+00AD or ­.

a cute kitten

konservatorio konservatorio

a cute kitten

põllumajandusministeerium

a cute kitten

vervoerdersaansprakelijkheidsverzekering

a cute kitten

vaðlaheiðarvegavinnuverkfærageymsluskúr

a cute kitten

precipitevolissimevolmente

a cute kitten

nebeprisikiškiakopūstlapiaujančiuosiuose

a cute kitten

dziewięćdziesięciokilkuletniemu

a cute kitten

anticonstitucionalmente

a cute kitten

cyfrwngddarostynedigaeth

The cat demo

Please open in Codepen yourself and try.

See the Pen The horizontal overflow problem by Chen Hui Jing (@huijing) on CodePen.

If nested scrolling…

Nested scrolling: when both the page and a component has overflow

https://codepen.io/wgao19/pen/BaVBvEY
Basic example
Component scroll blocks page scroll

…then how?

First, ask yourself:

  • Is it really necessary?
  • If it is —
    • give the page enough margin so it is easier for users to scroll the page when intended
    • differentiate inner component and page more clearly, display the scrollbar, etc.

If stacked scrolling due to iFrame…

Trapped! Argh… 😩
No more stacked scrollbars from iFrame 😍

…you may try:

  • Statically setting the iFrame height to be a known height that is enough for its inner content
  • Dynamically setting iFrame height

Maybe you wanted things to scroll horizontally…

  • e.g., a row of images overflowing the width of mobile screen with free horizontal scrolling
  • e.g., carousel where horizontal swiping triggers pagination

Can is can, but…

Let's not do something like this:

Let's not do something like this

The touch-action property

https://huijing.github.io/touch-action/

Panning done right

Credit: https://www.benjaminzander.org/

Scaling down a big, complex app to smaller screen

The viewport meta tag

<meta name="viewport" content="width=device-width, initial-scale=1" />

Do you know that there are two viewports on mobile browsers?

The visual viewport is the part of the page that’s currently shown on-screen. And the size follows the actual screen size.

However, the CSS layout, especially percentual widths, are calculated relative to the layout viewport, which can be considerably wider than the visual viewport.

https://www.quirksmode.org/mobile/viewports2.html

viewport meta tag in action

Demo time!

<meta name="viewport" content="width=1600" />

But then hor…

  • By setting the layout viewport tag for this purpose, it “invalidates” responsive design
  • There’s a discrepancy between “layout size” and “actual size” of a component
  • Fonts can end up too small

Not just a technical problem though

What if your website owner is not a technical person and has no developers around them?

a shrugging chicken

10q errbadee!