admin管理员组文章数量:1331091
Does anyone know what javascript effects are being used to create the navbar effect on lesscss where the navbar only bees fixed to the top after scrolling beyond a certain point. If anyone has actual code examples, or links to tutorials, that'd be appreciated.
Does anyone know what javascript effects are being used to create the navbar effect on lesscss where the navbar only bees fixed to the top after scrolling beyond a certain point. If anyone has actual code examples, or links to tutorials, that'd be appreciated.
Share Improve this question edited Oct 12, 2012 at 2:08 snakesNbronies asked Oct 11, 2012 at 22:27 snakesNbroniessnakesNbronies 3,9209 gold badges46 silver badges74 bronze badges 01 Answer
Reset to default 6it's a javascript check using the window.onscroll
event
in the HTML source near the top:
window.onscroll = function () {
if (!docked && (menu.offsetTop - scrollTop() < 0)) {
menu.style.top = 0;
menu.style.position = 'fixed';
menu.className = 'docked';
docked = true;
} else if (docked && scrollTop() <= init) {
menu.style.position = 'absolute';
menu.style.top = init + 'px';
menu.className = menu.className.replace('docked', '');
docked = false;
}
};
本文标签: htmlJavascript fixedtop navbar only after scrollingStack Overflow
版权声明:本文标题:html - Javascript fixed-top navbar only after scrolling - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742271524a2444393.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论