返回顶部的button的效果

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
ul,li{
list-style: none;
}
ul li{
height: 30px;
border-bottom: 1px solid salmon;
line-height: 30px;
}
.return-top{
width: 20px;
height: 20px;
background: black;
opacity: 0.5;
display: none;
position: fixed;
bottom: 20px;
right: 20px;
}
.div1{
height: 900px;
width: 100%;
background: sandybrown;
}
</style>
</head>
<body>
<ul>
<li class="a">1</li>
</ul>
<div class="div1">

</div>
<div class="return-top">

</div>
</body>
<script src="js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){


$(window).scroll(function(){
if($(window).scrollTop()>=200){
$('.return-top').show();
}else{
$('.return-top').hide();
}
})

})
</script>


</html>

posted @ 2017-04-01 10:46  i'mpossible  阅读(93)  评论(0编辑  收藏  举报