简单版—返回顶部

页面右下角返回顶部

html



<div class="sriLink">
    <div class="back_top" onclick="window.scrollTo(0,0);return false" style="display: none;">
        <a href="javascript:void(0);"></a>
    </div>
    <div class="go_aboutUs">
        <a href="/aboutus" target="_blank">关于<br>我们</a>
    </div>
    <div class="go_feedBack">
        <a href="javascript:void(0);" target="_blank">意见<br>反馈</a>
    </div>
</div>

css


.sriLink{
    position: fixed;
    right: 50%;
    margin-right: -665px;
    bottom: 90px;
    z-index: 100;
}
.sriLink a{
    display: block;
    width: 50px;
    height: 50px;
    background: #eceded;
    text-align: center;
    padding-top: 8px;
    color: white;
    border-radius: 3px;
    margin-top: 5px;
    line-height: 16px;
}
.sriLink .back_top a {
    background: #e4e4e4 url(../image/back_top.png) no-repeat center;
}

js


/*滚动事件*/
window.addEventListener('scroll',function(e){
    var t = document.documentElement.scrollTop || document.body.scrollTop;
    if(t > 400 ){
        $('.back_top').show();
    }else{
        $('.back_top').hide();
    }
})
/*全局页面中间内容高度*/
$().ready(function(){
    var Height = $(window).height();
    var h = (Height - 212)+'px' //头部和底部总高为212
   $('.sriContainer').css('min-height',h);
})

posted @ 2018-05-29 10:12  撑船的摆渡人  阅读(246)  评论(0编辑  收藏  举报