不用錨點(diǎn)也可以平滑滾動(dòng)到頁(yè)面的指定位置實(shí)現(xiàn)代碼
更新時(shí)間:2013年05月08日 17:15:50 作者:
在不適用錨點(diǎn)的情況下也可以平滑滾動(dòng)到頁(yè)面的指定位置,看樣子還不錯(cuò)嗎,具體處理程序如下,感興趣的朋友可以參考下哈,希望對(duì)你有所幫助
不用錨點(diǎn)也可以平滑滾動(dòng)到頁(yè)面的指定位置
<!DOCTYPE html>
<html >
<head>
<meta content="text/html; charset=utf-8" />
<title>ScrollTo:平滑滾動(dòng)到頁(yè)面指定位置</title>
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<style type="text/css">
.nav{width:500px;margin:10px auto;}
.nav li{float:left; width:100px; height:24px; line-height:24px}
.box{height:500px}
.box h3{height:32px; line-height:32px; padding-left:20px; font-size:14px}
.clear{clear:both}
html,body,div,span,h1,h2,h3,h4,h5,h6,p,pre,a,code,em,img,small,strong,sub,sup,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}
a{color:#007bc4/*#424242*/; text-decoration:none;}
a:hover{text-decoration:underline}
ol,ul{list-style:none}
table{border-collapse:collapse;border-spacing:0}
body{height:100%; font:12px/18px "Microsoft Yahei", Tahoma, Helvetica, Arial, Verdana, "\5b8b\4f53", sans-serif; color:#51555C; background:#162934 url(../images/body_bg.gif) repeat-x}
img{border:none}
#main{width:910px; min-height:600px; margin:30px auto 0 auto; background:#fff; -moz-border-radius:12px;-khtml-border-radius: 12px;-webkit-border-radius: 12px; border-radius:12px;}
h2.top_title{margin:4px 20px; padding-top:15px; padding-left:20px; padding-bottom:10px; border-bottom:1px solid #d3d3d3; font-size:18px; color:#a84c10;}
</style>
<script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script>
<script type="text/javascript" src="http://jt.875.cn/js/scrollto.js"></script>
<script type="text/javascript">
$(function(){
$(".nav_pro").click(function(){
$.scrollTo('#pro',500);
});
$(".nav_news").click(function(){
$.scrollTo('#news',800);
});
$(".nav_ser").click(function(){
$.scrollTo('#ser',1000);
});
$(".nav_con").click(function(){
$.scrollTo('#con',1200);
});
$(".nav_job").click(function(){
$.scrollTo('#job',1500);
});
});
</script>
</head>
<body>
<div id="main">
<h2 class="top_title">ScrollTo:平滑滾動(dòng)到頁(yè)面指定位置</h2>
<ul class="nav">
<li><a href="#" class="nav_pro">產(chǎn)品展示</a></li>
<li><a href="#" class="nav_news">新聞中心</a></li>
<li><a href="#" class="nav_ser">服務(wù)支持</a></li>
<li><a href="#" class="nav_con">聯(lián)系我們</a></li>
<li><a href="#" class="nav_job">人才招聘</a></li>
</ul>
<div class="clear"></div>
<div id="pro" class="box">
<h3>產(chǎn)品展示</h3>
</div>
<div id="news" class="box">
<h3>新聞中心</h3>
</div>
<div id="ser" class="box">
<h3>服務(wù)支持</h3>
</div>
<div id="con" class="box">
<h3>聯(lián)系我們</h3>
</div>
<div id="job" class="box" style="height:680px">
<h3>人才招聘</h3>
</div>
</div>
</body>
</html>
JS 插件:scroll to
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html >
<head>
<meta content="text/html; charset=utf-8" />
<title>ScrollTo:平滑滾動(dòng)到頁(yè)面指定位置</title>
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<style type="text/css">
.nav{width:500px;margin:10px auto;}
.nav li{float:left; width:100px; height:24px; line-height:24px}
.box{height:500px}
.box h3{height:32px; line-height:32px; padding-left:20px; font-size:14px}
.clear{clear:both}
html,body,div,span,h1,h2,h3,h4,h5,h6,p,pre,a,code,em,img,small,strong,sub,sup,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}
a{color:#007bc4/*#424242*/; text-decoration:none;}
a:hover{text-decoration:underline}
ol,ul{list-style:none}
table{border-collapse:collapse;border-spacing:0}
body{height:100%; font:12px/18px "Microsoft Yahei", Tahoma, Helvetica, Arial, Verdana, "\5b8b\4f53", sans-serif; color:#51555C; background:#162934 url(../images/body_bg.gif) repeat-x}
img{border:none}
#main{width:910px; min-height:600px; margin:30px auto 0 auto; background:#fff; -moz-border-radius:12px;-khtml-border-radius: 12px;-webkit-border-radius: 12px; border-radius:12px;}
h2.top_title{margin:4px 20px; padding-top:15px; padding-left:20px; padding-bottom:10px; border-bottom:1px solid #d3d3d3; font-size:18px; color:#a84c10;}
</style>
<script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script>
<script type="text/javascript" src="http://jt.875.cn/js/scrollto.js"></script>
<script type="text/javascript">
$(function(){
$(".nav_pro").click(function(){
$.scrollTo('#pro',500);
});
$(".nav_news").click(function(){
$.scrollTo('#news',800);
});
$(".nav_ser").click(function(){
$.scrollTo('#ser',1000);
});
$(".nav_con").click(function(){
$.scrollTo('#con',1200);
});
$(".nav_job").click(function(){
$.scrollTo('#job',1500);
});
});
</script>
</head>
<body>
<div id="main">
<h2 class="top_title">ScrollTo:平滑滾動(dòng)到頁(yè)面指定位置</h2>
<ul class="nav">
<li><a href="#" class="nav_pro">產(chǎn)品展示</a></li>
<li><a href="#" class="nav_news">新聞中心</a></li>
<li><a href="#" class="nav_ser">服務(wù)支持</a></li>
<li><a href="#" class="nav_con">聯(lián)系我們</a></li>
<li><a href="#" class="nav_job">人才招聘</a></li>
</ul>
<div class="clear"></div>
<div id="pro" class="box">
<h3>產(chǎn)品展示</h3>
</div>
<div id="news" class="box">
<h3>新聞中心</h3>
</div>
<div id="ser" class="box">
<h3>服務(wù)支持</h3>
</div>
<div id="con" class="box">
<h3>聯(lián)系我們</h3>
</div>
<div id="job" class="box" style="height:680px">
<h3>人才招聘</h3>
</div>
</div>
</body>
</html>
JS 插件:scroll to
相關(guān)文章
web前端開(kāi)發(fā)JQuery常用實(shí)例代碼片段(50個(gè))
本文給大家展示50個(gè)jquery代碼片段,這些代碼能夠給你的javascript項(xiàng)目提供幫助,需要的朋友快來(lái)學(xué)習(xí)一下吧2015-08-08
jQuery實(shí)現(xiàn)表格文本框淡入更改值后淡出效果
這篇文章主要介紹了jQuery實(shí)現(xiàn)表格文本框淡入更改值后淡出效果的實(shí)現(xiàn)代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò),需要的朋友可以參考下2016-09-09
用jquery實(shí)現(xiàn)點(diǎn)擊欄目背景色改變
用jquery如何實(shí)現(xiàn)點(diǎn)擊一欄目實(shí)現(xiàn)欄目變色,再點(diǎn)擊另一欄目也變色,但原來(lái)的變回原色,本文提供解決方法,需要了解的朋友可以參考下2012-12-12
JQuery設(shè)置文本框和密碼框得到焦點(diǎn)時(shí)的樣式
設(shè)置文本框和密碼框得到焦點(diǎn)時(shí)的樣式,通過(guò)jquery來(lái)實(shí)現(xiàn),需要注意的是中間用逗號(hào)隔開(kāi),感興趣的朋友可以參考下2013-08-08
jquery分頁(yè)插件jquery.pagination.js實(shí)現(xiàn)無(wú)刷新分頁(yè)
這篇文章主要介紹了jquery分頁(yè)插件jquery.pagination.js實(shí)現(xiàn)無(wú)刷新分頁(yè)的相關(guān)資料,需要的朋友可以參考下2016-04-04
jquery easyUI中ajax異步校驗(yàn)用戶名
這篇文章主要為大家詳細(xì)介紹了jquery easyUI中ajax異步校驗(yàn)用戶名,感興趣的小伙伴們可以參考一下2016-08-08

