Css:
Copy Code code as follows:
. backtotop {
Display:none;
width:18px;
line-height:1.2;
padding:5px 0;
Background-color: #000;
Color: #fff;
font-size:12px;
Text-align:center;
position:fixed;
_position:absolute;
right:10px;
bottom:100px;
_bottom: "Auto";
Cursor:pointer;
Opacity:. 6;
Filter:alpha (opacity=60);
}
jquery Code
Copy Code code as follows:
(function () {
var $backToTopTxt = "Back to top", $backToTopEle = $ (' <div clas s= "BackToTop" ></div> "). Appendto ($ (" body "))
. Text ($BACKTOTOPTXT). attr (" title ", $backToTopTxt). Click ( function () {
$ ("html, Body"). Animate ({scrolltop:0}, 120);
}), $backToTopFun = function () {
var st = $ (document). ScrollTop (), Winh = $ (window). Height ();
(St > 0) $backToTopEle. Show (): $backToTopEle. Hide ();
Position under//ie6
if (!window. XMLHttpRequest) {
$backToTopEle. css ("Top", St + winh-166);
}
};
$ (window). Bind ("scroll", $backToTopFun);
$ (function () {$backToTopFun ();});}) ();: