Finally, My blog got rid of bx-error codes.. come back soon and read the tutorial...
TopBottom

How to add a go to top and go to bottom button

Posted by Nitesh Kothari at 01 September 2008 | Post views: counter
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Many websites or blogs have more than 2-3 posts at homepage. I find it very irritating to scroll down to bottom manually. Using a simple JavaScript Code we can scroll to top or bottom of a page at lightening speed. You can see two fixed arrows at the left bottom of Wolverine Hacks blog.

How to add Go to top and bottom button:

a) CSS Code: Copy and paste the following code between <head> and </head>. Most advisable place would be just before ]]></b:skin> or </b:skin>

.gototop{
background:url(http://wolverinehacks.googlepages.com/arrow_top.gif)no-repeat;
display:block;_display:none;
position:fixed;
z-index:9999;
text-indent:-9999px;
width:17px;
height:17px;
overflow:hidden;
outline:none;
left:3px;
bottom:30px;}

.gotobottom {
background:url(http://wolverinehacks.googlepages.com/arrow_down.gif)no-repeat;
width:17px;
height:17px;
display:block;
_display:none;
position:fixed; z-index:9999;
text-indent:-9999px;
overflow:hidden;
outline:none;
left:3px;
bottom:5px;
}

b) HTML Code: Copy and paste the following code between <body> and </body>.

<a class='gototop' href='javascript:scroll(0,0)' title='Scroll to top of this page'>Top</a><a class='gotodown' href='#footer' title='Go to Bottom'>Bottom</a>

Save it and check your blog.

How to customize CSS and HTML Code

a) CSS Code:

.gototop{
background:url(http://wolverinehacks.googlepages.com/arrow_top.gif)no-repeat;
display:block;_display:none;
position:fixed;
z-index:9999;
text-indent:-9999px;
width:17px;
height:17px;
overflow:hidden;
outline:none;
left:3px;
bottom:30px;}

.gotobottom {
background: url(http://wolverinehacks.googlepages.com/arrow_down.gif)no-repeat;
width:17px;
height:17px;
display:block;
_display:none;
position:fixed; z-index:9999;
text-indent:-9999px;
overflow:hidden;
outline:none;
left:3px;
bottom:5px;
}

1. Change the background image link in red to the desired image source.
2. To change the position of these Buttons, change the values in red of left:3px;bottom:5px;. For example if you want to place these buttons to right bottom, then replace left:3px;bottom:5px; to right:3px;bottom:5px;

b) HTML Code:

<a class='gototop' href='javascript:scroll(0,0)' title='Scroll to top of this page'>Top</a><a class='gotobottom' href='#footer' title='Go to Bottom'>Bottom</a>

Go to bottom button is set to #footer. If you do not have #footer in your CSS then, search for #footer-wrapper or #footer-wrap.

Final Words
I hope this tutorial is easy to understand. If you do not understand anything then leave a comment. I will reply asap. So, what do you have to say about it?

8 comments:

Liza said...

I just wrote about doing this using the HTML "Name" attribute, but haven't considered also doing it through CSS.

Aravind Reddy said...

Hi Nitesh,
I included the CSS Menu and Go to Top and Bottom buttons in my blog. thanks a lot for the code.
For the top and bottom buttons I am unable to see the images in IE7. Is there any fix for this.
Thanks.

online gambling history said...

I am amazed at how many of these big name retailers have such poorly designed buttons. I am a small art glass and jewelry website and took the time to design my own buttons. I used to have “buy now” and switched to “add to cart” and seem to have increased conversion.

Rusli Zainal Sang Visioner said...

Hi Nitest,
Thank a lot for sharing this posting. It is really useful for me.

Business Marketing Resources said...

nice hacks mate , thanks for sharing this
anyway, those link to wolverine hacks is redirected to this site

Post a Comment

Thank you for commenting at NiteshKothari.com. I follow "U comment I comment" movement. All the comment are dofollow. Please do not spam or leave meaningless or short comments. I expect you to leave me meaningful, relative and genuine comments. Thank you.

Blog Widget by LinkWithin