单击顶部导航时如何进行向下滚动效果(向下滑动).
How to do scroll down effect(slide down) when click on top navigations..?
单击顶部导航时如何实现滚动效果(向下滑动)。。?
示例网站
下面是我创建的一个函数,它使用jQuery。因此,请确保您的HTML页面中包含jQuery。
var NCRscroll = function(){
var animateScroll=function(e,t,n,r){r=r||-60;n=n||2e3;$(e).on("click",function(){$("html, body").animate({scrollTop:$(t).offset().top+r},n);return false})}
/*
NCRScroll has four parameters link that users click on (link). Id is to where on the page you want to scrollTo (id).
Speed is the speed at which the scroll feature goes to the section of the page that you desire.
The default value for speed is 2000 milliseconds which is 2 seconds. So it doesn't have to be set if you like the speed.
The last parameter is the offset which is defaulted to -60. You can change this to your desire. -60 work in this template.
*/
//Demo of how your call should look.
animateScroll("#showcaselink", "#showcase", 1000, 20);
};
然后调用函数。
NCRscroll();
$('a').click(function(){
$('html, body').animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 1000);
return true;
});
使用这个jQuery。
HTML:
<ul id="nav">
<li><a href="/">Home</a></li>
<li class="dropdown">
<a href="#">Parent</a>
<ul class="childnav">
<li><a href="#">Child 1</a></li>
<li><a href="#">Child 2</a></li>
</ul>
</li>
</ul>
CSS:
ul.childnav {
position:relative;
display:none;
}
li.dropdown:hover ul.childnav {
display:block;
}
我相信一个简单的网络搜索就会给你这样的东西。
相关文章:
- 单击顶部导航时如何进行向下滚动效果(向下滑动).
- 使用滚动溢出-x进行无限循环
- 当静态元素与滚动上的固定元素位置重叠时进行检测
- 使用编辑器进行并排标记预览滚动
- 可以'使用inter.js进行测试时不要滚动
- 网络驱动程序中使用的向下滚动功能从网页的哪个部分进行搜索
- 如何避免在自由jqgrid中单击单元格进行水平滚动编辑
- 允许在隐藏溢出的情况下进行触摸滚动
- 避免在视差滚动效果中对图像进行不必要的缩放
- 使用javascript只滚动一个图像进行图像滚动
- 如何在ng视图中进行页面渲染后的平滑滚动
- 如何在jcarousel上进行图像滚动
- 通过用户滚动量进行检测
- 是否可以在滚动时进行“对齐”效果
- 根据页面上的滚动位置进行多种样式更改
- 制作一个滚动视图,在用户向下滚动时进行更新
- D3使用滚动条进行缩放,滚动条宽度和高度可根据缩放比例进行调整
- 通过滚动位置进行动画,在窗口大小调整时效果相同
- 使用Isotop/jQUery在tumblr上使用无限滚动功能进行专栏化
- 对javascript中的ajax滚动内容进行排序