Jquery导航阶梯效果

 * {
            margin: 0;
            padding: 0;
        }
        
        .contain {
            width: 70px;
            height: 350px;
            overflow: hidden;
            position: fixed;
            top: 20px;
            left: 200px;
            float: left;
            position: fixed;
            left: 30px;
            top: 10px;
        }
        
        .block {
            width: 70px;
            overflow: hidden;
        }
        
        .block li {
            list-style: none;
            width: 70px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            background-color: black;
            color: #fff;
            margin-bottom: 5px;
            cursor: pointer;
        }
        
        .block li:hover {
            background-color: blue;
        }
        
        .content {
            float: left;
            margin-left: 200px;
            width: 400px;
            height: 3000px;
            /* overflow: hidden;
            overflow-y: auto; */
        }
        
        .content div {
            width: 400px;
            height: 300px;
            line-height: 300px;
            text-align: center;
            background-color: black;
            margin-bottom: 20px;
            color: #fff;
            font-size: 22px;
        }
        
        .top {
            width: 42px;
            height: 42px;
            background-color: blue;
            position: fixed;
            right: 0;
            bottom: 0;
            color: #fff;
            text-align: center;
        }
<div class="contain">
        <ul class="block">
            <li data-in="go1">1</li>
            <li data-in="go2">2</li>
            <li data-in="go3">3</li>
            <li data-in="go4">4</li>
            <li data-in="go5">5</li>
            <li data-in="go6">6</li>
        </ul>
    </div>
    <div class="content">
        <div id="go1">11</div>
        <div id="go2">22</div>
        <div id="go3">33</div>
        <div id="go4">44</div>
        <div id="go5">55</div>
        <div id="go6">66</div>
    </div>
    <div class="top">返回顶部</div>
 $(".block li").click(function(e) {
            var target = e.target;
            var id = $(target).data("in")
            $('html,body').animate({
                scrollTop: $("#" + id).offset().top

            }, 800)
        })
        $(".top").click(function() {
            $('html,body').animate({
                scrollTop: 0
            }, 800)
        })
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值