JS+CSS implementation returns to the top button __JS

Source: Internet
Author: User

Turn from: http://www.jb51.net/article/80304.htm

Modify the section, and then directly copy and paste can be used (put the position you are happy to be good)

Required Material: http://fontawesome.io/(download this icon library)

<style> p#back-to-top{position:fixed;
        } p#back-to-top a{Text-align:center;
        Color: #000;
        /* Use the Transition property in CSS3 to add a gradient effect to the text in the Jump link * *-MOZ-TRANSITION:COLOR1S;
    P#back-to-top a:hover{color: #000011;
        P#back-to-top a span{background-color: #ffffff;
        border:1px solid #cccccc;
        /* Use the Transition property in CSS3 to add a gradient effect to the <span> label background color * *-MOZ-TRANSITION:BACKGROUND1S;
    #back-to-top a:hover span{background-color: #f0f0f0; } </style> <p id= "back-to-top" ><a href= "#top" &Gt;<span><i class= "fa fa-chevron-up" aria-hidden= "true" ></i></span></a></p> <script src= "Http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" ></script> <script> $ (
        Document). Ready (function () {///First hides #back-to-top $ ("#back-to-top"). Hide (); When the scroll bar is positioned below 600 pixels from the top, the jump link appears, or it disappears $ (function () {$ (window). Scroll (function () {.
                window). scrolltop () >600) {$ ("#back-to-top"). FadeIn (500);
                }else{$ ("#back-to-top"). fadeout (500);
            }); When you click the Jump link, go back to the top position of the page $ ("#back-to-top"). Click (function () {$ (' body,html '). Animate ({scrolltop:0},5
            return false;
}); </script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.