zoukankan      html  css  js  c++  java
  • 返回顶部的动态显示与隐藏

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>实现动态的显示回到顶部与否</title>
    <style>
    /*返回顶部*/
    .back_top {45px;height:45px;background:url(back_top_new.png) 0 0;position:fixed;left:50%;margin-left:500px;bottom:105px;display:none;}
    .back_top:hover{background:url(images/back_top_new.png) 0 -46px;}
    </style>
    </head>

    <body>
    <a title="返回顶部" href="javascript:void(0)" class="back_top"></a>
    <script src="js/jquery-1.11.0.min.js"></script>
    <script>
    var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel"; //FF doesn't recognize mousewheel as of FF3.x
    if (document.attachEvent) //if IE (and Opera depending on user setting)
    document.attachEvent("on"+mousewheelevt, function(e){
    var t=document.body.scrollTop+document.documentElement.scrollTop;
    if(t==0){
    $(".back_top").css("display","none");
    }
    else{
    $(".back_top").css("display","block");
    }
    });
    else if (document.addEventListener) //WC3 browsers
    document.addEventListener(mousewheelevt, function(e){
    var t=document.body.scrollTop+document.documentElement.scrollTop;
    if(t==0){
    $(".back_top").css("display","none");
    }
    else{
    $(".back_top").css("display","block");
    }
    }, false);

    </script>
    </body>
    </html>

    梦想还是要有的,万一实现了呢
  • 相关阅读:
    File类
    Java运算符
    JAVA语法
    数据库-子查询
    爬取笔趣阁_完本书籍
    爬取动物图片源码
    爬取电影天堂上最新电影的下载链接的源码
    pyinstaller的安装、使用、出错解决办法
    Emmet插件使用方法总结
    Markdown基本语法
  • 原文地址:https://www.cnblogs.com/amandaff/p/4024541.html
Copyright © 2011-2022 走看看