Visible Vertical Scrollbar (in Firefox)
In Firefox, the vertical scrollbar disappears when content fits inside the viewport. This makes several layout types shift position, typically by 10 to 20 pixels.
A workaround became possible in 2004 but it stands repeating and spreading around, imho.
Am I bothered?
It’s a usability problem: users must learn two positions for important things:
- Start of lines to begin scan-reading content.
- Edges of left or right navigation links.
- Edges of tabs in a horizontal menu to ensure you click the correct item.
- Start of breadcrumb trail to check current location.
Consider this:
- Do user want their browser to make layouts inconsistent?
- Do authors want their layout to shift position?
I’m guessing the answer is “no” on both counts.
Instructions for Firefox Users
You can make the vertical scrollbar visible all the time. Read the instructions before starting.
Always Visible Scrollbar
As used in Internet Explorer.
- Right-click this
userContent.css
file. - Select Save Link As...
You should usually should save it in
C:\Documents and Settings\[Windows Login Name]\Application Data\Mozilla\Firefox\Profiles\[profile name]\chrome\
, on these conditions:- You are using an English version of Windows 2000 or Windows XP.
- The drive labelled
C:
is the one which has Windows installed on it. [Windows Login Name]
is the name you select at the “welcome” screen when starting Windows. (If you don’t have a “welcome” screen, this should beAll Users
.)[profile name]
is a random string of 8 letters, a dot (.
) and then some more letters.
For example, I would save it to
C:\Documents and Settings\Ben\Application Data\Mozilla\Firefox\Profiles\lo3h7uay.default\chrome\
.Failing that, try following the Where is my Mozilla profile located? tutorial.
- Click the Save button.
- Exit Firefox and then start it again.
You will now have a robust vertical scrollbar always visible.
Visible when needed Scrollbar
As in Firefox 2. These instructions prevent websites altering this.
- Follow all the “Always Visible Scrollbar” instructions above.
- Open the
userContent.css
file in a text editor, such as Notepad. Find this:
/* Visible vertical scrollbar which disables correctly and allows normal horizontal scrollbar behaviour. */ html { overflow-y: scroll !important; }
Replace with this:
/* Hidden vertical scrollbar which appears when needed and allows normal horizontal scrollbar behaviour. */ html { overflow-y: auto !important; }
- Save the file by selecting File > Save in the text editor’s menu.
You will now have a robust vertical scrollbar visible when needed.
Uninstall
- Locate the
userContent.css
file: - Rename it to
userContent-scroll.css
or something.
Or, if you want to keep other things in that file:
- Open the
userContent.css
file in a text editor, such as Notepad. Find this:
/* Visible vertical scrollbar which disables correctly and allows normal horizontal scrollbar behaviour. */ html { overflow-y: scroll !important; }
Replace with this:
/* Visible vertical scrollbar which disables correctly and allows normal horizontal scrollbar behaviour. */ html { /* overflow-y: scroll !important; */ }
- Save the file by selecting File > Save in the text editor’s menu.
You’ll need to exit Firefox and start it again for any changes to take effect.
Technical Details
The file userContent.css
is a user stylesheet. The supplied file contains this:
/* Visible vertical scrollbar which disables correctly and allows normal horizontal scrollbar behaviour. */
html {
overflow-y: scroll !important;
}
Pros
- Applies to all websites you visit.
- Permits default horizontal scrollbar behaviour (doesn’t break the web).
- Vertical scrollbar disables when there is nowhere to scroll vertically.
- Avoids “scrolling to nowhere” bugs present in some other methods.
- You opt-in and out-out rather than have it forced on you.
- You prevent authors of websites or themes affecting your preference.
- Takes very little CSS.
- The CSS is readable.
- Is being standardised as part of CSS3:
:root
pseudo-class if you want it for anything displayed in the browser.overflow-x
andoverflow-y
properties.
- Media independant (HTML, XHTML, XML, images and so on).
Cons
- About 20 pixels less viewport width for wide but short resources.
- Requires some detective work to find
userContent.css
.
Instructions for Authors
You can add it your your web pages in this form:
/* Visible vertical scrollbar which disables correctly, allows normal horizontal scrollbar behaviour and can be overruled by userContent.css. */
html {
overflow-y: scroll;
}
Pros
- Degrades safely in browsers with no support for it.
- Users can still opt-out via
userContent.css
.
Cons
- Not supported by all browsers with the hide/show scrollbar behaviour, afaik.
Background
Dates back to Bugzilla in March 2001.
Since then, various solutions and arguments gravitated to Jon Hicks’s site. The solution here is Lachlan ‘Lachy’ Hunt’s from there.
- Firefox defaults to
overflow: auto;
, more or less. Some users much prefer this. - Hacks with
height: 100.01%
prevent the scrollbar disabling on short pages. - Hacks with
margin-bottom: 1px;
add a “scrolling to nowhere” bug. overflow: -moz-scrollbars-vertical;
hides the horizontal scrollbar.