[英]How to have two different types of navigation bar one fixed and one static with different menu items?
How can we have fixed navigation bar having same behaviour like this on website https://ooomf.com/ and also with two different type of menu items. 我们如何在网站https://ooomf.com/上固定具有相同行为的导航栏,并同时具有两种不同类型的菜单项。
For example on the website above they have stories, how it works , blog and login at the top menu and when you scroll down in fixed menu "login" gets replaced with "start your project" button. 例如,在上面的网站上,它们具有故事,工作原理,博客和登录,位于顶部菜单,当您在固定菜单中向下滚动时,“登录”将替换为“启动项目”按钮。
How do we accomplish that using css/jquery in bootstrap 3 ? 我们如何在bootstrap 3中使用css / jquery做到这一点?
Help would be appreciated. 帮助将不胜感激。
Thank you. 谢谢。
You simply apply in bootstrap with afix 您只需使用Afix在bootstrap中应用
$('#navbar').affix({
offset: {
top: 50
}
});
Update Via data attributes To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. 通过数据属性更新要轻松地将词缀行为添加到任何元素,只需将data-spy =“ affix”添加到要监视的元素。 Use offsets to define when to toggle the pinning of an element.
使用偏移量定义何时切换元素的固定。
<div data-spy="affix" data-offset-top="60">
...
</div>
You can set up on data-offset-top="200"
when you need to show. 您可以在需要显示时在
data-offset-top="200"
进行设置。 here is the example 这是例子
DEMO http://jsfiddle.net/6P5sF/56/ 演示http://jsfiddle.net/6P5sF/56/
Reference: http://getbootstrap.com/javascript/#affix 参考: http : //getbootstrap.com/javascript/#affix
Here is an example with 2 navbars. 这是一个带有2个导航栏的示例。 The
affix
component is used to pin the 2nd navbar to the top once the user has scrolled past the top header. 用户滚动到顶部标题上方后,
affix
组件将第二个导航栏固定在顶部。 You can use CSS z-index
to position the 2nd navbar over the first... 您可以使用CSS
z-index
将第二个导航栏放在第一个导航栏上...
#topNav {
z-index:-1;
}
#nav {
width: 100%;
position:static;
top:-32px;
}
#nav.affix {
position: fixed;
top: 0;
z-index:10;
-webkit-transition: all .6s ease-in-out;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.