css:
.back {
1. position: fixed;
2. width: 64px;
3. height: 64px;
4. background: url(["../images/back.fw.png"](file:///D:/%E9%A1%B9%E7%9B%AE/DRAS%20html%20develop/DRAS(welcome)/resources/images/back.fw.png)) no-repeat;
5. right: 48px;
6. bottom: 20px;
7. cursor: pointer;
}
js:
var wH = $(window).height();//获取窗口一屏的高度
$(window).scroll( function(e) {
if ($(window).scrollTop() > wH){ //当滑动的距离大于一屏的时候,让向上的小图显示,否则隐藏
$( '.back').show ();
} else{
$('.back' ).hide() ;
}
});
$('.back'). click(function(e) {
$('html,body' ).animate({'scrollTop': '0'}, 300);
});