首页 > Web开发 > 详细

网页常用片段-回到顶部

时间:2019-09-25 18:01:10      阅读:97      评论:0      收藏:0      [点我收藏+]

1、html

<div id="totop"></div>

2、css

#totop {
    width: 51px;
    height: 57px;
    cursor: pointer;
    position: fixed;
    right: 10px;
    top: 60%;
    background: #fff url(../images/totop.png) no-repeat center 50%;
    border: 1px solid #e2e2e2;
    opacity: 0.85;
    z-index: 100;
    display: none;
    mix-blend-mode: exclusion;
}
#totop:hover {
    opacity: 1;
}

3、js

$("#totop").click(function() {
  $("html,body").animate({scrollTop:0}, 300);
}); 
$(window).scroll(function () {
  if ($(window).scrollTop() > 800) {
    $("#totop").fadeIn(300);
  }
  else {
    $("#totop").fadeOut(300);
  }
});

 

网页常用片段-回到顶部

原文:https://www.cnblogs.com/congfeicong/p/11585645.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!