[他山之石] - [回到顶部小火箭]

回到顶部小火箭

回到顶部小火箭

回到顶部小火箭

<link href="http://files.cnblogs.com/files/lingr7/cnblog-scroller.css" type="text/css" rel="stylesheet">
 <script src="http://files.cnblogs.com/files/lingr7/scrollspy.js" type="text/javascript"></script>
 <script src="http://files.cnblogs.com/files/lingr7/stickUp.min.js" type="text/javascript"></script>
<script src="http://files.cnblogs.com/files/lingr7/cnblog-scroller.js" type="text/javascript"></script>

<style>
#back-top {
     position: fixed;
     bottom: 10px;
     right: 5px;
     z-index: 99;
}
#back-top span {
     width: 50px;
     height: 64px;
     display: block;
     background:url(http://images.cnblogs.com/cnblogs_com/seanshao/855033/o_rocket.png) no-repeat center center;
}
#back-top a{outline:none}
</style>
<script type="text/javascript">
$(function() {
    // hide #back-top first
    $("#back-top").hide();
    // fade in #back-top
    $(window).scroll(function() {
        if ($(this).scrollTop() > 500) {
            $('#back-top').fadeIn();
        } else {
            $('#back-top').fadeOut();
        }
    });
    // scroll body to 0px on click
    $('#back-top a').click(function() {
        $('body,html').animate({
            scrollTop: 0
        }, 800);
        return false;
    });
});
</script>
<p id="back-top" style="display:none"><a href="#top"><span></span></a></p>

posted @ 2020-11-09 17:47  澄轶  阅读(118)  评论(0编辑  收藏  举报