Tuesday, February 3, 2015
如何让页面快速滚动至页尾
在范本里的<head>与</head>标签之间加入以下程式码:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'/>
<script type='text/javascript'>
$(function(){
$("#gotop").click(function(){
jQuery("html,body").animate({
scrollTop:$(document).height()
},3000);
});
$(window).scroll(function() {
if ( $(this).scrollTop() > 0){
$('#gotop').fadeIn("fast");
} else {
$('#gobottom').stop().fadeOut("fast");
}
});
});
</script>
<style type='text/css'>
<!--
#gotop { /* gotop的css語法 */
z-index: 1;
display: none;
position: fixed;
right: 0px;
bottom: 55px;
padding: 15px 1px;
font-size: 15px;
background: purple;
color: white;
cursor: pointer;
}
-->
</style>
然后使用HTML模块,在里面加入:
<b:if cond="data:blog.isMobile"> <!-- gotop在mobile不顯示的html語法 --><br /><b:else><br /><div id="gotop"><center>∇</center></div> <!-- gotop的html語法 --><br /></b:else></b:if>
Labels:
博客
Subscribe to:
Post Comments (Atom)



No comments:
Post a Comment