zoukankan      html  css  js  c++  java
  • 返回顶部js

    backToTop.js:

    (function () {
        var $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
            .click(function () {
                $("html, body").animate({ scrollTop: 0 }, 120);
            }), $backToTopFun = function () {
                var st = $(document).scrollTop(), winh = $(window).height();
                (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
                //IE6下的定位
                if (!window.XMLHttpRequest) {
                    $backToTopEle.css("top", st + winh - 166);
                }
            };
        $(window).bind("scroll", $backToTopFun);
        $(function () { $backToTopFun(); });
    })();

    样式设置:

    .backToTop {
        display: none;
        background:url(../images/go_top.gif);
        background-repeat:no-repeat;
        background-position:0px 0px;
        width:50px;
        height:50px;
        color: #fff;
        font-size: 12px;
        text-align: center;
        position: fixed;
        _position: absolute;
        right: 2px;
        bottom: 2px;
        _bottom: "auto";
        cursor: pointer;
        opacity: .6;
        filter: Alpha(opacity=60);
    }
    .backToTop:hover
    {
        background:url(../images/go_top.gif);
        background-repeat:no-repeat;
        background-position:0px -100px;
    }
  • 相关阅读:
    autolayout--约束的优先级
    CV
    iOS及Mac开源项目和学习资料(超级全面)
    终端中命令总结
    git使用方法笔记
    Shell命令
    git-在控制台下向gitHub中的repository中上传一个文件
    iOS
    iOS -雪花动画
    copy语法
  • 原文地址:https://www.cnblogs.com/vinsonLu/p/4049869.html
Copyright © 2011-2022 走看看