css 到顶部按钮w / FA - https://paulund.co.uk/how-to-create-an-animated-scroll-to-top-with-jquery

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 到顶部按钮w / FA - https://paulund.co.uk/how-to-create-an-animated-scroll-to-top-with-jquery相关的知识,希望对你有一定的参考价值。

$(document).ready(function(){
	
	//Check to see if the window is top if not then display button
	$(window).scroll(function(){
		if ($(this).scrollTop() > 100) {
			$('.scrollToTop').fadeIn();
		} else {
			$('.scrollToTop').fadeOut();
		}
	});
	
	//Click event to scroll to top
	$('.scrollToTop').click(function(){
		$('html, body').animate({scrollTop : 0},800);
		return false;
	});
	
});
<div class='scrolltop'>
    <div class='scroll icon'><i class="fa fa-4x fa-angle-up"></i></div>
</div>
.scrolltop {
  display:none;
  width:100%;
  margin:0 auto;
  position:fixed;
  bottom:20px;
  right:10px;
  z-index: 9999;
}

.scroll {
  position:absolute;
  right:20px;
  bottom:20px;
  background-color:$black;
  padding:20px;
  text-align: center;
  margin: 0 0 0 0;
  cursor:pointer;
  transition: 0.5s;
}

.scroll:hover {
  background-color:$pink;
  transition: 0.5s;
}

.scroll:hover .fa {
  padding-top:-10px;
}

.scroll .fa {
  font-size:30px;
  margin-top:-5px;
  margin-left:1px;
  transition: 0.5s;
  color:$white;
}

以上是关于css 到顶部按钮w / FA - https://paulund.co.uk/how-to-create-an-animated-scroll-to-top-with-jquery的主要内容,如果未能解决你的问题,请参考以下文章

JS简单实现“滚动到顶部“按钮悬浮效果,在一定高度才显示 - 替代CSS粘性定位position:sticky方案

scss 滚动时的UI到顶部/页面到顶部按钮

添加滚动到顶部按钮(Ionic 2 | Typescript)

添加滚动到顶部按钮(Ionic 2 | Typescript)

每次打开时如何使 div 模态滚动到顶部?

显示滚动到顶部如果顶部!= 0