欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)帶有動(dòng)畫效果的回到頂部和底部代碼

 更新時(shí)間:2015年11月04日 09:33:03   作者:企鵝  
這篇文章主要介紹了jQuery實(shí)現(xiàn)帶有動(dòng)畫效果的回到頂部和底部代碼,涉及jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)操作頁面元素屬性的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)帶有動(dòng)畫效果的回到頂部和底部代碼。分享給大家供大家參考,具體如下:

這款動(dòng)畫版的回到頂部和底部效果代碼,也算是比較常見的一款網(wǎng)頁特效了,像淘寶網(wǎng)就有這種效果,使用了jQuery插件,加入了動(dòng)畫效果。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/jquery-animate-style-scroll-top-buttom-codes/

具體代碼如下:

<!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>
<title>動(dòng)畫版的回到頂部和底部效果代碼</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<style type="text/css">
body{padding:0px;margin:0px;}
#roll_top,#fall,#ct{position:relative;cursor:pointer;height:40px;width:15px;}
#roll_top{background:url(images/roll.png) no-repeat;}
#fall{background:url(images/roll.png) no-repeat 0 -80px;}
#ct{background:url(images/roll.png) no-repeat 0 -40px;}
#roll{display:block;width:15px;margin-right:-508px;position:fixed;right:50%;top:50%;_margin-right:-507px;_position:absolute;_margin-top:300px;_top:expression(eval(document.documentElement.scrollTop));}
</style>
<!--[if IE]>
<style type="text/css">
/* 修正IE6振動(dòng)bug */
html,body{background-image:url(about:blank);background-attachment:fixed;}
</style>
<![endif]-->
<script type="text/javascript" src="jquery1.3.2.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
  $('#roll_top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); 
  $('#ct').click(function(){$('html,body').animate({scrollTop:$('.ct').offset().top}, 800);});
  $('#fall').click(function(){$('html,body').animate({scrollTop:$('.footer,.footer_a').offset().top}, 800);});
});
</script>
</head>
<body>
預(yù)覽效果時(shí)左下角會(huì)提示錯(cuò)誤,而且看不到效果,刷新一下就可以看到效果了<br>
<div class="head">這里是頁面頂部</div>
<div id="roll">
  <div title="回到頂部" id="roll_top"></div>
  <div title="轉(zhuǎn)到底部" id="fall"></div>
</div>
<div id="content" style="height:2000px;"></div>
<div class="footer">這里是頁面底部</div>
</body>
</html>

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論