September 28, 2014 at 7:05 pm #55068
Keymaster
Add following code after body tag in header.php to add Back to Top button.
<script>
jQuery(function(){
jQuery(document).on( 'scroll', function(){
if (jQuery(window).scrollTop() > 100) {
jQuery('.scroll-top-wrapper').addClass('show');
} else {
jQuery('.scroll-top-wrapper').removeClass('show');
}
});
});
jQuery(function(){
jQuery(document).on( 'scroll', function(){
if (jQuery(window).scrollTop() > 100) {
jQuery('.scroll-top-wrapper').addClass('show');
} else {
jQuery('.scroll-top-wrapper').removeClass('show');
}
});
jQuery('.scroll-top-wrapper').on('click', scrollToTop);
});
function scrollToTop() {
verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0;
element = jQuery('body');
offset = element.offset();
offsetTop = offset.top;
jQuery('html, body').animate({scrollTop: offsetTop}, 500, 'linear');
}
</script>
<style>
.scroll-top-wrapper {
position: fixed;
opacity: 0;
visibility: hidden;
overflow: hidden;
text-align: center;
z-index: 99999999;
background-color: #777777;
color: #eeeeee;
width: 50px;
height: 48px;
line-height: 48px;
right: 30px;
bottom: 30px;
padding-top: 2px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
border-bottom-left-radius: 2px;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.scroll-top-wrapper:hover {
background-color: #888888;
}
.scroll-top-wrapper.show {
visibility:visible;
cursor:pointer;
opacity: 1.0;
}
.scroll-top-wrapper i.fa {
line-height: inherit;
}
</style>
<div class="scroll-top-wrapper ">
<span class="scroll-top-inner">
<i class="icon-circle-arrow-up icon-2x"></i>
</span>
</div>