效果预览(http://www.qh66.net/):
HTML代码:
<!-- go top btn -->
<a href="javascript:void(0);" id="goTopButton" class="gotop_btn"> </a>
<script type="text/javascript">
$(document).ready(function(){
$('#goTopButton').click(function(event){
$('html,body').animate({scrollTop:0},300);
});
$(window).scroll(function(event){
if($(this).scrollTop() > 0){
if($.browser.ie6){
$('#goTopButton').css('top',$(this).scrollTop() + $(this).height() - 100);
}
if($('#goTopButton').css('display') == 'none'){
$('#goTopButton').fadeIn();
}
}else{
$('#goTopButton').fadeOut();
}
});
});
</script>
CSS样式:
/* gotop_btn */
.gotop_btn { display:none; position:fixed; _position:absolute; left:50%; bottom:140px; width:21px; height:70px; margin-left:485px; background:url(../images/backtop.gif) no-repeat; }
.gotop_btn:hover { background-position:-21px 0; text-decoration:none; }
图片: