首页 > 网页设计 > 返回顶部的前台编程

返回顶部的前台编程

返回顶部的前台编程

<!-- 回到顶部-->
<style>
a.W_gotop {
display: none;
position: fixed;
_position: absolute;
width: 22px;
height: 85px;
line-height: 12px;
left: 50%;
bottom: 100px;
margin-left: 500px;
margin-bottom: 5px;
background-color: #F2F2F2;
border: 1px solid #CCCCCC;
border-radius:2px;
text-align: center;
text-decoration: none;
}
a.W_gotop span {
cursor: pointer;
display: block;
height: 73px;
padding-top: 10px;
border: 1px solid #FFFFFF;
text-decoration: none;
}
a.W_gotop em {
cursor: pointer;
text-decoration: none;
font-style: normal;
font-weight: normal;
}
.icon_gotop{
background: url(images/gotop.png) no-repeat;
}
.W_gotop:hover .icon_gotop {
background: url(images/gotop_focus.png) no-repeat;
}
.W_ico {
display: inline-block;
height: 12px;
width: 12px;
margin-bottom: 5px;
}
.W_txt{
color: #808080;
}
</style>
<a id="base_scrollToTop" style="visibility: visible;">
<span>
<em></em>
<em>返回顶部</em>
</span>
</a>

<script type="text/javascript">
$(function(){
var gotop = $(".W_gotop")
gotop.click(function(){
$("html,body").animate({scrollTop:0},500)
});

$(window).scroll(function(){
if($.browser.msie && ($.browser.version == "6.0") && !$.support.style){//如果IE6
gotop.css({"top":($(window).scrollTop()+$(window).height()-100)+"px","position":"absolute"});
}
if($(window).scrollTop()<=50){
gotop.fadeOut();
}else{
gotop.fadeIn();
}
});
});


本文固定链接: http://www.devba.com/index.php/archives/428.html | 开发吧

报歉!评论已关闭.