Forcing scrollbars (now even better)

17 Aug 2004

The massive trend of centering content horizontally brings with it a small problem. When moving from pages with short to long content, a nasty shift happens in Opera, Mozilla and Safari as the window makes room for the scrollbars. The only way to avoid this is to force scrollbars to appear all the time.

Here are a few solutions, and as you would expect, they each have their own pros and cons:

html>body { height: 800px; }

For: Simple, and works in most situations. This is the one I tend to use. The First-child selector hides the rule from IE windows that always adds a vertical scrollbar gutter anyway.
Against: Doesn’t work on large resolution monitors. Also, where it does add scrollbars constantly, there may be no content to see. Possibly confusing for users.

html>body { overflow:scroll; }

For: This does a better job at being less confusing. In Safari, this just adds scrollbar gutters, in others it adds scrollbars, but with a very small overflow length. Therefore, doesn’t confuse users with scrollbars for no content.
Against: It looks damn ugly as it adds horizontal scrollbars as well as vertical.

#Content p.bstext {
        font-size:216px;
        font-weight:900;
        line-height:130px;
        letter-spacing:-69px;
        overflow:hidden;
        color:#FFF;
        background:transparent;
}

This technique was found at the Web Standards Awards. I haven’t tried this one out yet, but on the face of it, it looks like an over-complication.

Update

Thanks to Patrick Lauke who came up with this genius solution:

html { height: 100%; margin-bottom: 1px; }

This adds a tiny amount of vertical scroll (1px no less), so users won’t think that there is content that they’re missing. This will also work on any resolution screen. I’ve tested this in Safari, Omniweb 5, Firefox on OS X, and it works like a dream! The only browser I could find that had a problem with it was (guess!) IE 5 Mac.

Recent Posts

The Symbol Sourcebook

08 Jun 2018

Differences between Icon and Logo Design on This is HCD Podcast

10 Apr 2018

Twelve South PencilSnap

01 Apr 2018

The Infinite Canvas

09 Feb 2018

Blade Runner 2049

14 Oct 2017

iPad Pro Pencil loop

11 Oct 2017

Instagram Hickstagram

  • 19 Jun 2018

  • 17 Jun 2018

    There’s something I love about this bit of road coming into Leafield

  • 09 Jun 2018

    Ride out to Kelmscott to test the new frame! Nice 40 mile loop in the sunshine ☺️

  • 09 Jun 2018

    The things you find on Freecycle. Tempted to reply that the council might want it back?

  • 09 Jun 2018

    Lovely morning dog walk at North Leigh Common

  • 07 Jun 2018

    Signs of wife

  • 30 May 2018

    O triptych

  • 28 May 2018

    Today’s working view

  • 24 May 2018

    Waiting…

  • 23 May 2018

    Dozing off

Contact us

Call Jon on +44 (0)7917 391536, email or tweet @hicksdesign.

Alternatively, pop in for tea and cake at the studio…

Hicks
Wenrisc House
Meadow Court
Witney, OX28 6ER
United Kingdom