jquery返回頂部特效

來源:互聯網
上載者:User

標籤:

 

<style>    p#back-to-top{position:fixed; bottom:100px;right:10px; display: none; }    p#back-to-top a{ text-align:center;  text-decoration:none;  color:#d1d1d1;  display:block;  width:30px;        /*使用CSS3中的transition屬性給跳轉連結中的文字添加漸層效果*/        transition:color 1s; -moz-transition:color 1s;        -webkit-transition:color 1s;        -o-transition:color 1s;}    p#back-to-top a span{        background:url(images/ico.jpg) no-repeat; display:block;height:30px;  width:30px;margin-bottom:5px;        /*使用CSS3中的transition屬性給<span>標籤背景顏色添加漸層效果*/        transition:background 1s;  -moz-transition:background 1s;-webkit-transition:background 1s;-o-transition:background 1s;}</style>

 

 1 <div style="width: 100%; height: 3000px;"></div> 2 <p id="back-to-top"><a href="#top"><span></span>返回頂部</a></p> 3  4 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script> 5 <script> 6     $(function(){ 7         $(window).scroll(function(){ 8             if($(window).scrollTop()>=100){ 9                 $("#back-to-top").fadeIn(1500); //緩慢的將段落淡入10             }11             else{12                 $("#back-to-top").fadeOut(1500); //緩慢的將段落淡出13             }14         })15         $("#back-to-top").click(function(){16            $(‘body.html‘).animate({scrollTop},1000);17            return false;18        })19     })20 </script>

 

jquery返回頂部特效

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.