Press "Enter" to skip to content

Scroll Down To Show The Anchor Link To Go To The Top With The Animation

Scroll down to show the anchor link to go to the top with the animation. It is the simplest implementation of a smooth back-to-top functionality using jQuery, JavaScript, and CSS/CSS3.

animated scroll to top button codepen, back to top scroll animation, back to top examples, back to top button pure javascript, scroll to top script, vanilla js back to top

A JavaScript Library to Display Link/URL Preview On Hover | Hyperlinks

How to make use of it:

1. Create an anchor link for the back to top button.

<a href="#myAnchor" class="go-top">
  Icon, Text, Button, etc...
</a>

2. CSS is required to position the back to the top button.

.go-top {
  display: block;
  width: 40px;
  height: 40px;
  line-height: 35px;
  text-align: center;
  font-size: 30px;
  position: fixed;
  bottom: -40px;
  right: 20px;
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  transition: all 1s ease;
  background-color: #404040;
  color: #FFFFFF;
  text-decoration: none;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
}

.go-top.show { bottom: 20px; }

.go-top:hover {
  background-color: #5DBA9D;
  color: #FFFFFF;
}

3. Load the required jQuery JavaScript library at the end of the document.

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 

4. Javascript to add/remove CSS classes to back button up when scrolling down/up.

$(window).scroll(function(event){
  var scroll = $(window).scrollTop();
    if (scroll >= 50) {
      $(".go-top").addClass("show");
    } else {
      $(".go-top").removeClass("show");
    }
});

5. Smoothly scroll the window back to the top of your webpage when you click the back-to-top button.

$('a').click(function(){
  $('html, body').animate({
    scrollTop: $( $(this).attr('href') ).offset().top
  }, 1000);
});

Minimal Back To Top Functionality with jQuery and CSS3 Plugin/Github, back to top plugin, back to top smooth scroll jquery


See Demo And Download

Official Website(mattiabericchia): Click Here

This superior jQuery/javascript plugin is developed by mattiabericchia. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.