在Windows系統(tǒng)上安裝PHP運(yùn)行環(huán)境文字教程
757
2023-12-09
本文實(shí)例講述了jquery實(shí)現(xiàn)網(wǎng)頁(yè)的頁(yè)面平滑滾動(dòng)效果代碼。分享給大家供大家參考,具體如下:
這款網(wǎng)頁(yè)頁(yè)面平滑滾動(dòng)jquery代碼,點(diǎn)擊鏈接會(huì)讓網(wǎng)頁(yè)平滑滾動(dòng)到鏈接對(duì)應(yīng)的位置。
運(yùn)行效果截圖如下:
在線演示地址如下:
http://demo.gimoo.net/js/2015/jquery-link-scroll-page-codes/
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>頁(yè)面平滑滾動(dòng)jquery代碼</title> <script type="text/javascript" src="http://www.gimoo.net/t/1904/jquery1.3.2.js"></script> <script type="text/javascript"> (function($){ $.extend($.fn,{ scrollTo:function(time,to){ time=time||800; to=to||1; $('a[href*=#]', this).click(function(){ if (location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']'); if ($target.length) { if (to == 1) { $('html,body').animate({ scrollTop: $target.offset().top }, time); } else if(to==2){ $('html,body').animate({ scrollLeft: $target.offset().left }, time); }else{ alert('argument error'); } return false; } } }); } }); })(jQuery); </script> <script type="text/javascript" language="javascript"> $(function(){ // $("#a111").scrollTo(600,2妯???) $("#a111").scrollTo(700) });</script> <style type="text/css" > html{ _overflow:hidden} body {margin:0; height:100%; overflow-y:auto} #a111 { position:fixed; width:1000px; left:10%;} * html #a111 {position:absolute;} #a111 a{ display:block; width:50px; height:20px; background:#000; color:#fff; float:left;} #a111 a:hover{ background:#f60;} #b11{ height:1000px; background:#090;} #b22{ height:1000px; background:#fc0;} #b33{ height:1000px; background:#09d;} </style> </head> <body> <div id="a111"> <a >mao1</a> <a >mao2</a> <a >mao3</a> </div> <div id="b11">網(wǎng)頁(yè)1</div> <div id="b22">網(wǎng)頁(yè)2</div> <div id="b33">網(wǎng)頁(yè)3</div> </body> </html>
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
#免責(zé)聲明#
本站[綠夏技術(shù)導(dǎo)航]提供的一切軟件、教程和內(nèi)容信息僅限用于學(xué)習(xí)和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請(qǐng)用戶自負(fù)。本站信息來(lái)自網(wǎng)絡(luò)收集整理,版權(quán)爭(zhēng)議與本站無(wú)關(guān)。您必須在下載后的24個(gè)小時(shí)之內(nèi),從您的電腦或手機(jī)中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請(qǐng)支持正版,購(gòu)買注冊(cè),得到更好的正版服務(wù)。我們非常重視版權(quán)問(wèn)題,如有侵權(quán)請(qǐng)郵件[admin@lxwl520.com]與我們聯(lián)系進(jìn)行刪除處理。敬請(qǐng)諒解!