Home>

This animated version of the top and bottom effect code,It is also a relatively common web page effect.Like Taobao has this effect,Use the jquery plugin and add animation effects.

The screenshot of the running effect is as follows:

The online demo address is as follows:

The specific code is as follows:

<! 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>Animated back to top and bottom effect code</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">
/* Fix ie6 vibration 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>
An error will be displayed in the lower left corner when previewing the effect.
And see no effect,You can see the effect after refreshing it<br>
<div>Here is the top of the page</div>
<div>
  <div></div>
  <div></div>
</div>
<div></div>
<div>Here is the bottom of the page</div>
</body>
</html>
  • Previous Double colon :: Use case in PHP
  • Next JS implements custom simple webpage soft keyboard effect code