Tuesday, January 1, 2013

Adding A Scroll to Button To Your Blog

I have been trying to figure out how to add a scroll to top button on my blog. I really like when other blogs or Pinterest have a button that all I have is click and the page scrolls to the top. Easy Peasy! Many of the other bloggers were helpful but..... they tell you to design a cute button first. Ugh! No designing yet for this girl I just want to add a button. Nothing fancy. So I found this blog Cheers to School where she gives you step by step with pictures how to add a button. Yahooooooo! Guess what? It worked, it worked! So I wanted to share my awesome find.


Here is a screen shot of my button.


Steps to adding a scroll to top button... if you need pictures here is the blog Cheers to School.
1. Go to your blogger dashboard, then Dashboard, then Edit HTML
2. Hit Ctr+F (command and find) the following code in your template: (This did not work for me so I scrolled down until I found what I needed) 

</body>

3. Under </body> copy and paste the following code:
<style type="text/css">
#w2b-StoTop {-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px; width:100px;background-color: #EEEEEE;background-color: rgba(238, 238, 238, 0.6);filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#99EEEEEE',EndColorStr='#99EEEEEE');text-align:center;padding:5px;position:fixed;bottom:10px;right:10px;cursor:pointer;color:#444;text-decoration:none;border:1px solid #C9C9C9;}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type='text/javascript'>
$(function() {
$.fn.scrollToTop = function() {
$(this).hide().removeAttr("href");
if ($(window).scrollTop() != "0") {
$(this).fadeIn("slow")
}
var scrollDiv = $(this);
$(window).scroll(function() {
if ($(window).scrollTop() == "0") {
$(scrollDiv).fadeOut("slow")
} else {
$(scrollDiv).fadeIn("slow")
}
});
$(this).click(function() {
$("html, body").animate({
scrollTop: 0
}, "slow")
})
}
});
$(function() {
$("#w2b-StoTop").scrollToTop();
});
</script>
<a href='#' id='w2b-StoTop' style='display:none;'>Scroll to Top </a>

4. Click save your template and Ta Da!  You have a Scroll to the Top button!
 
Thanks again to Cheers to School.

Photobucket

2 comments:

Thanks for the comments. I LOVE comments.