Add Percentage Scrolling to your blog

Percentage Scrolling to blogger

Add Scrolling in percent ~Bloggerstricks4all
Adding Scrolling percentage effect to your blog i an amazing idea.It provides an accurate idea about the length of a webpage.I have seen this widget in many blog Templates and find out the code for it.Here I am presenting a tutorial about how to add this elegant widget to your blog. 





Go to Blogger → Templates → Edit HTML



 Find  ]]></b:skin> and paste the following just above it.

#scroll {
display: none;
position: fixed;
top: 0;
right: 20px;
z-index: 500;
padding: 3px 8px;
background-color: #2187e7;
color: #fff;
border-radius: 3px;
}
#scroll:after {
content: ” ”;
position: absolute;
top: 50%;
right: -8px;
height: 0;
width: 0;
margin-top: -4px;
border: 4px solid transparent;
border-left-color: #2187e7;
}



 After Doing the above step Find </head> and paste the below code just below it.
Note : You have to paste the code between </head> and <body>

<div id='scroll'></div>


After doing that Find </body> and paste the below code just above </body>


<script type='text/javascript'>
/*<![CDATA[*/
var scrollTimer = null;
$(window).scroll(function() {
var viewportHeight = $(this).height(),
scrollbarHeight = viewportHeight / $(document).height() * viewportHeight,
progress = $(this).scrollTop() / ($(document).height() - viewportHeight),
distance = progress * (viewportHeight - scrollbarHeight) + scrollbarHeight / 2 - $('#scroll').height() / 2;
$('#scroll')
.css('top', distance)
.text(' (' + Math.round(progress * 100) + '%)')
.fadeIn(100);
if (scrollTimer !== null) {
clearTimeout(scrollTimer);
}
scrollTimer = setTimeout(function() {
$('#scroll').fadeOut();
}, 1500);
});
/*]]>*/
</script>

Okay Now you are fully set now the visitors can see this effect on your blog


Last Words

If you need any help feel free to contact us. :)

Unknown

Hello, I'm just a small but a good blogger eager to help the newbies over blogging world. I love blogging because it taught me many things and also gave me my life i.e. Programming.

No comments:

Post a Comment