Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two vertical scrollbars in Firefox when using overflow-x:hidden

Ive just built a website for a client, and Ive got an odd problem that only occurs in Firefox browser.

At the top of the page I have a navigation bar that fills the width of the browser. Ive used the technique described here http://css-tricks.com/full-browser-width-bars/ to achieve the effect as semantically as possible. Then Ive had to place overflow-x:hidden on the html and body tags to prevent the user from being able to scroll off the right side of the screen.

This works great in every browser I've tested it in from Safari on Mac/PC, Opera, Chrome and heaven forbid, but even IE7, 8 & 9 wanted to play nice. But oh no Firefox just doesn't want to go along with it.

Although Ive no horizontal scroll bars which is the desired effect, Firefox has decided to double up on the amount of vertical scrollbars. I can't scroll horizontally if using a mouse, but when I use the trackpad on the Mac, the vertical movement is restricted, meaning I cant scroll down the page and if I do a two finger swipe the page scrolls off horizontally into oblivion.

The only thing I have found on google and elsewhere is that this behaviour is a bug in Firefox?

Any help with this annoyance is greatly appreciated, Many Thanks.

Update: Added Code

Basically the code is this as theres too much show it all. I would point you to the site but the client doesn't want it live yet. Here we go:

<nav id="menu">
    <ul>
        <li>Menu Item 1</li>
        <li>Menu Item 2</li>
        <li>Menu Item 3</li>
    </ul>
</nav>

Then the css is this for a fullwidth browser bar as the link above:

html,body{
    overflow-x: hidden; /*This prevents the user from scrolling horizontally*/
}

#menu{
    position: relative;
    background: blue;
}

#menu:before, #menu:after{
    content:'';
    position: absolute;
    background: inherit;
    top: 0;
    bottom: 0;
    width: 9999px; /*huge width to ensure bar fills browser*/
}

#menu:before{
    right: 100%;
}

#menu:after{
    left: 100%;
}
like image 553
Martin Harvey Avatar asked Feb 03 '12 17:02

Martin Harvey


People also ask

Why do I have two vertical scrollbars?

double vertical scrollbar appears when tree view height is too long #255.

How do I get rid of the double scroll bar?

Double scrollbar appears on the website So you should either turn off the Overflow-X option, as you most likely won't need it anyway, or find the height CSS code and remove it.

What are the two types of scrollbars?

There are two types of scroll bars: vertical and horizontal.


1 Answers

Just had a similar issue come up; my solution was to simply add:

html, body {height:100%;}

And that solved it. Just wanted to post it here 'cause this kept popping up in the search results.

like image 192
Jon Schroeder Avatar answered Sep 17 '22 23:09

Jon Schroeder