mrpbennett
10/30/2012 - 5:33 PM

smooth scrolling top

smooth scrolling top

/*
JS Script
*/

<script>
  $('.toTopLink').bind('click',function(){
   $('html, body').animate({
      scrollTop:0
   }, $(window).scrollTop() / 3);
      return false;
   });
</script>
 
/*
HTML links for one page
*/

 <a name="top"></a>
 
 <a href="#top" class="toTopLink"><span>back to top</span></a>

/*
CSS for button
Plus media quieres for it vanishing
*/

.toTopLink {
    position: fixed;
    left:94%; 
    bottom:50%;
    width: 44px;
    height: 44px;
    font-variant: small-caps;
    text-align: center;
    background-image: url("img/chevron.png");
    background-position: left bottom;
        background-position-x: 0%;
        background-position-y: 100%;
    background-repeat: no-repeat;
}
@media(max-width:782px){.toTopLink{margin-left:85%}}
@media(max-width:480px){.toTopLink{display:none!important}}