Scroll to top

Δημιουργία ScrollToTop εικονιδίου με html, css, javascript

footer.php

<a href="#" class="scrollup">Scroll</a>

scripts.js

$(document).ready(function () {

    $(window).scroll(function () {
        if ($(this).scrollTop() > 1200) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    });

    $('.scrollup').click(function () {
        $("html, body").animate({
            scrollTop: 0
        }, 600);
        return false;
    });

});

style.css

.scrollup {
    width: 40px;
    height: 40px;
    position: fixed;
    bottom: 70px;
    right: 50px;
    display: none;
    text-indent: -9999px;
    background: url('img/scroll.png') no-repeat;
}

Leave a Reply

Your email address will not be published. Required fields are marked *