CSS trick: Always show scrollbars

I worked on a site a few weeks ago where the user wanted visible scrollbars no matter how much space the content takes up on the page. Internet Explorer is happy to oblige, just put in a overflow: scroll; in your CSS and your good to go. However, Mozilla Firefox wouldn’t play ball. A bit of Googling revealed Mozillas own implementation -
overflow: -moz-scrollbars-vertical;.

So to sum up, add the following CSS code to your site if you want the scrollbars visible at all times:

html {
     overflow: -moz-scrollbars-vertical;
     overflow: scroll;
}

12 Responses to “CSS trick: Always show scrollbars”

  1. ravi Says:

    Its really a good trick but doesn’t work in opera Please if you can tell it for opera

  2. Marty Says:

    Thx for this :) Its working perfectly – IE, FF, Opera, Safari. Thanx again :)

  3. Rick Says:

    Thanks so much… exactly what I was looking for!

  4. Jimmy K. Says:

    This code works well (I’m not going to lie, I’ve used it a lot), but it won’t validate in CSS 2.1.

  5. Mordy R. Says:

    Great Little Piece of code.
    It creates a horizontal scroll bar on the bottom of the page as well.

  6. Rob Koster Says:

    for vertical only scrollbar:

    html {
    overflow: -moz-scrollbars-vertical;
    overflow-y: scroll; //-y stands for the vertical scrollbar
    }

  7. Brian Says:

    Thanks for the vertical only tip Rob. I had a few pages in a center aligned website that didn’t require a scroll bar. Those pages lined up slightly left of the other pages which caused a jerky reaction when browsing. Your tip fixed that. Thanks!

  8. Jonas Says:

    @Rob: That causes the horisontal scrollbar to dissapear even if the browser window is too small for the page width. But that´s a easy fix:

    html {
    overflow: -moz-scrollbars-vertical;
    overflow-y: scroll;
    overflow-x: auto;
    }

  9. Paul Says:

    @Jonas

    To bad its not working in older IE versions. There i get an extra scrollbar and the normal one is not working anymore. I didn’t find a fix for that yet.

  10. aNj Says:

    This is working everywhere:

    html{height: 101%}

  11. Jason Says:

    Perfect thanks :) works well … (but not in Google chrome)

  12. Liz Says:

    Thanks a bunch!

Leave a Reply