代码
<div id="back-to-top">
<a href="#top" rel="external nofollow" ></a>
</div>
CSS
#back-to-top {
padding:2px 5px;
line-height:1em;
position:fixed;
bottom:50px;
right:5%;
cursor:pointer;
background:url(img/top.svg) no-repeat center 50%;
height:48px;
width:48px;
}
JS
<script type="text/javascript">
$(document).ready(function(){
//首先将#back-to-top隐藏
$("#back-to-top").hide();
//当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
$(function () {
$(window).scroll(function(){
if ($(window).scrollTop()>100){
$("#back-to-top").fadeIn(100);
}
else
{
$("#back-to-top").fadeOut(100);
}
});
//当点击跳转链接后,回到页面顶部位置
$("#back-to-top").click(function(){
$('body,html').animate({scrollTop:0},"speed");
return false;
});
});
});
</script>
顶部
酷!哈哈
现在基本都是主题自带了。
博客不折腾主题就像吃小龙虾不喝啤酒一样,浑身难受,又菜又爱玩
好多老板子没带,得自己折腾。其实我到希望模板制作者能经常更新模板,但是如果没有收益,更新就会失去动力--所以,只好自己折腾了。。。
收藏备用