• jQuery实现页面底部滑动置顶


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>jQuery实现页面底部滑动置顶 | alleyloft.com</title>
    <link type="text/css" rel="stylesheet" href="css/main.css" />
    <script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
    <script type="text/javascript">
        $(function(){
            //置顶按钮显示/隐藏实现
            $(window).scroll(function(){
                var w_height = $(window).height();//浏览器高度
                var scroll_top = $(document).scrollTop();//滚动条到顶部的垂直高度
                if(scroll_top > w_height){
                        $("#goto-top").fadeIn(500);
                    }else{
                        $("#goto-top").fadeOut(500);
                }
            });
        //置顶
        $("#goto-top").click(function(e){
                e.preventDefault();
                $(document.documentElement).animate({
                    scrollTop: 0
                    },200);
                //支持chrome
                $(document.body).animate({
                    scrollTop: 0
                    },200);
            });
        })
    </script>
    <style type="text/css">
        #goto-top {
            display:none;
            position:fixed;
            38px;
            height:36px;
            background:url(images/goto-top.png) no-repeat 0 0;
            bottom:40px;
            right:40px;
            -webkit-transition:all 0.2s;
            -moz-transition:all 0.2s;
            -o-transition:all 0.2s;
            transition:all 0.2s;
            z-index:9999;
        }
        #goto-top:hover {
            background:url(images/goto-top.png) no-repeat 0 -36px;
        }
    </style>
    </head>
       
    <body>
        <div class="header">
            <div class="logo">
                jQuery实现页面底部滑动置顶 <span>- alleyloft.com</span>
            </div>
        </div>
        <div class="placeholder"></div>
        <div class="nav">
            <div class="ul-box">
    <ul class="links">
    <li><a href="http://www.alleyloft.com" target="_blank" class="cur">小巷阁楼</a></li>
    <li><a href="http://www.alleyloft.com/blog" target="_blank">生活随笔</a></li>
    <li><a href="http://www.alleyloft.com/share" target="_blank">技术分享</a></li>
    <li><a href="http://www.alleyloft.com/psd" target="_blank">原创PSD作品</a></li>
    <li><a href="http://www.alleyloft.com/html" target="_blank">静态HTML模板</a></li>
    <li><a href="http://www.alleyloft.com/photo" target="_blank">个人随拍</a></li>
    <li><a href="http://www.alleyloft.com/index" target="_blank">音乐欣赏</a></li>
    <li><a href="http://www.alleyloft.com/aboutme" target="_blank">关于我</a></li>
    </ul>
            </div>
        </div>
        <div class="con">
            <div class="show">
                <div class="banner">
                    <a href="http://www.alleyloft.com/photo" target="_blank">
         <img alt="小巷阁楼-alleyloft" title="个人随拍" src="images/banner.jpg" />
                    </a>
                </div>
                <div class="article">
                    <!--文章内容区-->
                </div>
            </div>
        </div>
        <a href="#" title="返回顶部" id="goto-top"></a>
    </body>
    </html>
    
  • 相关阅读:
    制作IOS 后台极光推送时,遇到的小问题
    如何实现IOS_SearchBar搜索栏及关键字高亮
    使用WKWebView替换UIWebView,并且配置网页打电话功能
    [Creating an image format with an unknown type is an error] on cordova, ios 10
    面向对象语言还需要指针么?
    推荐一个简单好用的接口——字典序列化
    ITTC数据挖掘系统(六)批量任务,数据查看器和自由文档
    java的LINQ :Linq4j简明介绍
    别语言之争了,最牛逼的语言不是.NET,也不是JAVA!
    ITTC数据挖掘平台介绍(五) 数据导入导出向导和报告生成
  • 原文地址:https://www.cnblogs.com/lh123/p/3962539.html
Copyright © 2020-2023  润新知