Zum Inhalt springen

Scroll to Top

Aus Computech CMS Wiki

CSS

/* Scroll to top */ .scrolltop { display: none; background: url(images/scrolltop.png) no-repeat; width: 30px; height: 30px; position: fixed; right: 50px; bottom: 30px; cursor: pointer; }

Code

<div class="scrolltop"></div> <script type="text/javascript">

   $(document).ready(function(){
   $(window).scroll(function(){
   if ($(this).scrollTop() > 80) {
   $(".scrolltop").fadeIn('slow');
   }
 else {
   $(".scrolltop").fadeOut('slow');
   }
   });
   $(".scrolltop").click(function(){
   $("html, body").animate({ scrollTop: 0 }, 'slow');
   });
   });

</script>