Scrollbars in Firefox. Halp?! Let's break the rules.

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Re: Scrollbars in Firefox. Halp?! Let's break the rules.

Post by computerbp13 on Thu Jul 01, 2010 8:43 am
([msg=41121]see Re: Scrollbars in Firefox. Halp?! Let's break the rules.[/msg])

The solution is simple, though it requires JavaScript. When javascript isn't available the browser's default scroll bar will be used.
The concept is even simpler. Wrap your entire content in a div and set it to overflow: hidden. Then create your scrollbar in another div and place it along the side of the page. Sample:

Code: Select all
<!doctype html>
<title>Scrollbar Replacement Demo</title>
                  body { margin: 0; padding: 0; }
                  #maincontent { height: 100%; overflow: hidden; width: 100%; }
                  #scrollbar { bottom: 0; position: absolute; right: 0; top: 0; width: 17px; }
//Insert scrollbar code here (look into the scrollTop and scrollHeight for DOM elements (specifically #maincontent)
<div id="maincontent">
<!-- Main Content here -->
<div id="scrollbar">
<!-- HTML Scrollbar goes here -->

This is typically how scrollbars are customized on a page. Simply apply this strategy to the whole page and you can simulate your own scrollbar.
Hope this helps!
New User
New User
Posts: 9
Joined: Fri Jul 04, 2008 12:24 pm
Blog: View Blog (0)


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests