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(){
    $(&quot;#gotop&quot;).click(function(){
        jQuery(&quot;html,body&quot;).animate({
            scrollTop:$(document).height()
        },3000);
    });
    $(window).scroll(function() {
        if ( $(this).scrollTop() &gt; 0){
            $(&#39;#gotop&#39;).fadeIn(&quot;fast&quot;);
        } else {
            $(&#39;#gobottom&#39;).stop().fadeOut(&quot;fast&quot;);
        }
    });
});
</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>



No comments:

Post a Comment