當前位置:編程學習大全網 - 網站源碼 - Dreamweaver怎樣給網頁添加返回頂部按鈕?

Dreamweaver怎樣給網頁添加返回頂部按鈕?

1、頁面先寫好點擊到頂部的html代碼

2、監聽滾動條事件,超過某個高度點擊圖片,將滾動條置頂0,就能跳回頂部了

<div id="Gotop" class="gotop">Go</div>

css:

.gotop{ position:fixed; bottom:20px; right:20px; display:none; width:50px; height:50px; line-height:50px;....}

$(function(){

$(window).scroll(function() {

if($(window).scrollTop() >= 100){

$('.Gotop').fadeIn(300);//滾動條超出100出現

}else{

$('.Gotop').fadeOut(300); //否則隱藏

}

});

$('.Gotop').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});//點擊滾動到頂部

});

  • 上一篇:山西省人民醫院可以在網上掛號嗎?網址是什麽?
  • 下一篇:紅色警戒2如何晉升等級?
  • copyright 2024編程學習大全網