返回到頂部代碼

來源:互聯網
上載者:User
<html><head><meta name="viewport" content="width=device-width, initial-scale=1"><script src="http://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script><script>jQuery(document).ready(function($){        var offset = 300,        offset_opacity = 1200,        scroll_top_duration = 700,        $back_to_top = $('.cd-top');    $(window).scroll(function(){        ( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');        if( $(this).scrollTop() > offset_opacity ) {             $back_to_top.addClass('cd-fade-out');        }    });    $back_to_top.on('click', function(event){        event.preventDefault();        $('body,html').animate({            scrollTop: 0 ,            }, scroll_top_duration        );    });});</script><style>.cd-top {    display: inline-block;    height: 40px;    width: 40px;    position: fixed;    bottom: 40px;    right: 10px;    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);    overflow: hidden;    text-indent: 100%;    white-space: nowrap;    background: rgba(232, 98, 86, 0.8)        url(http://www.100sucai.com/img/demo/1335.svg) no-repeat center 50%;    visibility: hidden;    opacity: 0;    -webkit-transition: opacity .3s 0s, visibility 0s .3s;    -moz-transition: opacity .3s 0s, visibility 0s .3s;    transition: opacity .3s 0s, visibility 0s .3s;}.cd-top.cd-is-visible,.cd-top.cd-fade-out,.no-touch .cd-top:hover {    -webkit-transition: opacity .3s 0s, visibility 0s 0s;    -moz-transition: opacity .3s 0s, visibility 0s 0s;    transition: opacity .3s 0s, visibility 0s 0s;}.cd-top.cd-is-visible {    visibility: visible;    opacity: 1;}.cd-top.cd-fade-out {    opacity: .5;}.no-touch .cd-top:hover {    background-color: #e86256;    opacity: 1;}</style><title>Back To Top | Cody</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body>    返回頂部代碼    <div style="height: 1500px;"></div>    <div class="cd-top">Top</div></body></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.