<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{padding:0;margin:0;}
.top{ width:100%; height:100px; text-align: center; line-height: 100px;}
.nav{ width:100%; height:100px;}
.nav ul{width:100%; list-style: none;}
.nav ul li { float:left; line-height:100px;
text-align: center; width:25%; background:#0095cd;}
.fixed {position:fixed; top:0px;}
.cont1,.cont2,.cont3,.cont4{width:100%;height:400px; color:#fff;}
.cont1 {background:#00678e; text-align:center; line-height: 400px;}
.cont2 {background:#0F3A56; text-align:center; line-height: 400px;}
.cont3 {background:#33bbee; text-align:center; line-height: 400px;}
.cont4 {background:#7ca1f8; text-align:center; line-height: 400px;}
.footer { background:#68767b; text-align:center;line-height:200px;}
</style>
<script src="style/js/jquery-1.8.3.min.js"></script>
<script>
$(function(){
$(window).scroll(function(){
if ($(window).scrollTop() >= 100) {
$('.nav').addClass('fixed');
} else {
$('.nav').removeClass('fixed');
}
})
var _li = $('.nav').find('li');
_li.each(function(){
var index = $(this).index();
$(this).find('a').click(function(){
var len = index-1;
var numTop = getHeight(len);
$('html,body').animate({scrollTop: numTop + "px"},300);
})
})
})
function getHeight(index) {
var heightall = 0;
for(i=0;i<=index;i++){
heightall += 400;
}
return heightall;
}
</script>
</head>
<body>
<div class="top">这是顶部,高度为100px</div>
<div class="nav">
<ul>
<li><a>first</a></li>
<li><a>scond</a></li>
<li><a>third</a></li>
<li><a>four</a></li>
</ul>
</div>
<div class="cont1">this is content1</div>
<div class="cont2">this is content2</div>
<div class="cont3">this is content3</div>
<div class="cont4">this is content4</div>
<div class="footer">this is footer</div>
</body>
</html>

jquery 跳转到当前页面指定位置的更多相关文章

  1. html js点击按钮滚动跳转定位到页面指定位置(DIV)的方法代码

    一:通过html锚点实现滚动定位到页面指定位置(DIV):    如果我们要点击实现跳转的地方是一个html锚点,也就是点击一个A标签超链接实现跳转,可以把A标签的href属性直接指向跳转指定位置的d ...

  2. html锚点 点击跳转到页面指定位置

    本来是在看阮大神写的ajax教程,突然发现点击目录文字会跳转到相对应的文本内容,于是乎激发了我的兴趣. 这个究竟怎么做的,刚开始看的时候一知半解,找度娘就是:"点击跳转到页面指定位置&quo ...

  3. ScrollTo:实现平滑滚动到页面指定位置

    ScrollTo:实现平滑滚动到页面指定位置 ScrollTo是一款基于jQuery的滚动插件,当点击页面的链接时,可以平滑地滚动到页面指定的位置.适用在一些页面内容比较多,页面长度有好几屏的场合,本 ...

  4. coolite 获取新的页面链接到当前页面指定位置Panel的运用

    如下图所示,点击温州市文成县之前,右边是一片空白,点击后生成新的页面 html运用到了coolite的Panel控件 <Center> <ext:Panel ID="Pan ...

  5. jQuery跳转到页面指定位置

    @参考博客 var t = $("#id").offset().top;// 获取需要跳转到标签的top值 //$(window).scrollTop(t);// 跳转到指定位置 ...

  6. 锚点/JQ:点击导航跳到网页中的指定位置

    今天做了一个简单的功能,页面往下滚动到一定位置,顶部出现一个浮动的导航栏,点击导航栏标签,下面页面跳转到相应的区域.回到顶部,导航栏隐藏. 因为顶部有一个浮动的导航栏,所以跳转到下面页面的时候,总是盖 ...

  7. 通过href简单实现单击a链接跳转到页面指定位置

    在页面中点击a标签后,要使其跳到页面里面相应的地方,方法很简单,就是在a标签里面href中的内容和你要跳到这个区域的id同名即可,例如: <a href="#ppp" tar ...

  8. HTML实现跳转到页面指定位置

    <a href="#page1">跳转到页面1</a> <a href="#page2">跳转到页面2</a> ...

  9. JQuery插件:ScrollTo平滑滚动到页面指定位置

    1.准备jQuery库和scrollTo.js插件. <script type="text/javascript" src="js/jquery.js"& ...

随机推荐

  1. yii2框架安装

    注意:先把php.ini里面的php_openssl.dll扩展打开 1.下载yii2框架的文件包yii-advanced-app-2.0.7 2.打开路径为advanced下面的init.bat   ...

  2. 杭电1002-A + B Problem II

    #include<stdio.h>#include<string.h> int main(){    char str1[1001],str2[1001];    int t, ...

  3. AGPS 常见的两种定位模式

    SI 定位模式: 用户发起定位请求,辅助GPS 模块快速进行定位.时间在6秒-15秒之间. 这个方式能够有效的解决普通GPS 最快需要30秒时间获得卫星星历的搜星慢的问题,如果使用AGPS将通过中移动 ...

  4. ZOJ 3866 - Cylinder Candy

    3866 - Cylinder Candy Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu ...

  5. word中设置前几页为罗马数字,后几页设置为阿拉伯数字

    假如第1-5页摘要部分页脚要是罗马数字,第6页开始是正文部分是阿拉伯数字,起始页为1. WORD2003 1.将光标定位在第5页末尾处,在菜单栏中依次点击“插入——分隔符——(分节符类型)下一页”.按 ...

  6. JQuery知识快览之四—样式

    前面我们获取了对象集,本文介绍怎么控制对象集的样式 基本概念 在一个html页面中,我们有两种方式来控制一个对象的样式,用HTML attribute控制,或者用CSS类来控制,这两种方法虽然都能控制 ...

  7. windows tomcat配置大全

    Tomcat下JSP.Servlet和JavaBean环境的配置 第一步:下载j2sdk和tomcat:到sun官方站点()下载j2sdk,注意下载版本为Windows Offline Install ...

  8. wpf的研究和反思

    WPF的研究和反思 目前是否适合使用wpf      WPF(Windows Presentation Foundation)是微软推出的基于Windows Vista的用户界面框架,属于.NET F ...

  9. noi 7627 鸡蛋的硬度

    题目链接:http://noi.openjudge.cn/ch0206/7627/ 题目讲的二分其实是一个误导, d(i,j),表示当前最优策略时,最坏的情况下: 有 J 个鸡蛋,I 个可以怀疑的楼层 ...

  10. flask安装

    Flask简介 Flask算是小型框架,自开发伊始就被设计为可扩展的框架,它具有一个包含基本服务的强健核心.Flask有两个依赖:路由.调试.和web服务器网关接口(Web Server Gatewa ...