jquery实现的鼠标下拉滚动置顶效果
更新时间:2014年07月24日 11:47:33 投稿:whsnow
鼠标下拉滚动置顶效果想必大家在浏览网页时都有遇到过,下面有个不错的小例子,需要的朋友可以参考下
$(function(){
//置顶按钮显示/隐藏实现
$(window).scroll(function(){
var w_height = $(window).height();//浏览器高度
var scroll_top = $(document).scrollTop();//滚动条到顶部的垂直高度
if(scroll_top > w_height){
$("#goto-top").fadeIn(500);
}else{
$("#goto-top").fadeOut(500);
}
});
//置顶
$("#goto-top").click(function(e){
e.preventDefault();
$(document.documentElement).animate({
scrollTop: 0
},200);
//支持chrome
$(document.body).animate({
scrollTop: 0
},200);
});
})
</script>
<style type="text/css">
#goto-top {
display:none;
position:fixed;
width:38px;
height:36px;
background:url(images/goto-top.png) no-repeat 0 0;
bottom:40px;
right:40px;
-webkit-transition:all 0.2s;
-moz-transition:all 0.2s;
-o-transition:all 0.2s;
transition:all 0.2s;
z-index:9999;
}
#goto-top:hover {
background:url(images/goto-top.png) no-repeat 0 -36px;
}
</style>
</head>
相关文章
jquery中$(#form :input)与$(#form input)的区别
本节为大家介绍下jquery 中$(#form :input)与$(#form input)的区别,需要的朋友可以参考下2014-08-08
jQuery+HTML5+CSS3制作支持响应式布局时间轴插件
这篇文章主要为大家详细介绍了JQuery+HTML5+CSS3制作时间轴,支持响应式布局时间轴插件,感兴趣的小伙伴们可以参考一下2016-08-08


最新评论