固定底部,回到顶部

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>固定底部,回到顶部</title>
<style type="text/css">
#box{ bottom: 0; width: 200px; height: 10000px; border: 1px solid #0CC;}
.pos{ width: 200px; /*overflow-y:auto;overflow-x: hidden; */border: 1px solid #ccc;}
</style>
</head>

<body>
<script type="text/javascript" src="http://dict.cn/static/js/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$(window).scroll(function(){
var st = $(document).scrollTop();
var win = $(window).height();
if($.browser.msie && ($.browser.version == '6.0') && !$.support.style){
if(st-win>50){
$('#top').fadeIn('1500');
}else{
$('#top').fadeOut('1500');
}
$('#top').css({position:'absolute',bottom:'0px'});
}else{
if($(window).scrollTop() > 100){
$('#top').fadeIn('1500');
}else{
$('#top').fadeOut('1500');
}
$('#top').css({position:'fixed',bottom:'0px'});
}
});
$('#top').click(function(){
$('body,html').animate({scrollTop:0},200);
return false;
});

})
</script>
<div class="pos" id="top">
<p>gotoup</p>
<p>gotoup</p>
<p>gotoup</p>
<p>gotoup</p>
</div>
</body>
</html>

posted @ 2012-07-10 21:23  glelaine  阅读(252)  评论(0编辑  收藏  举报