jquery html 回到顶部 左下角

网页右下角 

手机端 

 

 

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>回到顶部 基于jquery</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="">
    
    <!-- JAVASCRIPTS -->
    <script src="./assets/js/jquery-1.10.2.min.js"></script>
    
    <style class="blockbyte-bs-style" data-name="content">

        /* 回到顶部相关样式  关键字 common-backtop-link */
        .common-backtop-link {
            position: fixed;
            right: 24px;
            bottom: 40px;
            width: 48px;
            height: 48px;
            background: #FFF;
            border: 1px solid #FFF;
            -webkit-border-radius: 50%;
            -moz-border-radius: 50%;
            -o-border-radius: 50%;
            border-radius: 50%;
            box-shadow: 0px 8px 40px 0px rgba(30, 35, 45, 0.08);
            cursor: pointer;
            z-index: 1000;
            display: none;
        }
        .common-backtop-link i{
            position: absolute;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
            background-image: url(assets/images/right-bar-back-top.png);
            background-repeat: no-repeat;
            background-position: center center;
            -webkit-border-radius:50%;
            -moz-border-radius:50%;
            -o-border-radius:50%;
            border-radius:50%;
        }
        .common-backtop-link:hover {
            background: linear-gradient(0deg, #FFFFFF,#F0F2F5);
        }
        .common-backtop-link:hover i{
            background-image: url(assets/images/right-bar-back-top-active.png);
        }
    </style>
</head>

<body>
    <div style="height: 3055px;" >
        <!-- 给个高度 滑动页面唤出 回到顶部 按钮 -->
    </div>

    <!-- 回到顶部相关代码  关键字 common-backtop-link 默认隐藏元素 display: block-->
    <div class="common-backtop-link" style="display: block;"><i></i></div>

    <script type="text/javascript">
        // 回到顶部相关js代码
        //滑动页面超过一个屏幕的高度时 则显示 回到顶部元素
        $(window).scroll(function(){
            $(this).scrollTop()>=$(window).height()?$('.common-backtop-link').show():$('.common-backtop-link').hide();
        })
        // $('.common-backtop-link').show();//默认显示回到顶部元素

        //点击回到顶部
        $(document).on('click','.common-backtop-link',function(){
            $("html,body").animate({
                scrollTop:0
            },300);
        })
    </script>
</body>
</html>

源码下载地址(带图标):

https://download.csdn.net/download/torpidcat/86063334

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值