<div id='to-top'> <i class='fa fa-lg fa-arrow-up to-top-icon'></i> <div class='to-top-caption'>to top</div> </div> <style>
cursor: pointer;
position: fixed;
right: 15px;
bottom: 15px;
width: 60px;
height: 60px;
margin-bottom: -200px;
text-align: center;
background: #FFF;
border: 5px solid rgba(0, 0, 0, .3);
border-radius: 100px;
box-shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 0 10px rgba(0, 0, 0, .1);
transition: .2s;
}
#to-top.show {
margin-bottom: 0;
}
#to-top:hover {
border-color: rgba(0, 0, 0, .5);
}
#to-top .to-top-icon {
line-height: 40px;
}
#to-top .to-top-caption {
margin-top: -12px;
font-size: .7em;
color: #000;
}
</style>
<script>
defer(function(){
var $toTop = $('#to-top')
.on('click', function(){
$('html, body').animate({ scrollTop: 0 }, 100);
});
var windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var $doc = $(document)
.on('scroll', function(e){
$toTop.toggleClass('show', $doc.scrollTop() > windowHeight);
});
});
</script>