zoukankan      html  css  js  c++  java
  • 网站返回顶部功能

    CSS:

      

    #scrolltop {display:none; position:fixed; bottom:80px; left:51%; _position:absolute; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight));
    margin-left:480px; font-size:14px; text-align:center; color:#f00; cursor:pointer; height:48px;44px;background:url(../images/top.png) no-repeat -44px 0;}
    #scrolltop:hover{border:0;padding:0;background:url(../images/top.png) no-repeat;}

    Jquery:

    <script type="text/javascript">
    $(function () {
    $(window).scroll(function () {
    var top = $(window).scrollTop();
    if (top > 500) {
    $("#scrolltop").fadeIn();
    } else {
    $("#scrolltop").fadeOut();
    }
    });
    $("#scrolltop").click(function () {
    $("html,body").animate({ scrollTop: 0 });
    });
    });
    </script>

    页面内容:

    <div id="scrolltop" style="display: none; "></div>

    图片:

  • 相关阅读:
    剑指Offer
    剑指Offer
    剑指Offer
    面积(area)
    最少步数
    细胞
    集合的前N个元素
    1~100卡特兰数(存一下hhhh)
    [Codeforces137C]History(排序,水题)
    [Codeforces676B]Pyramid of Glasses(递推,DP)
  • 原文地址:https://www.cnblogs.com/Italianetz/p/3227821.html
Copyright © 2011-2022 走看看