简体   繁体   English

如何具有两种不同类型的导航栏,其中一种是固定的,一种是静态的,具有不同的菜单项?

[英]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. 谢谢。

It is called a sticky navigation bar. 它称为粘性导航栏。 Now you can find many variations of this but here is a great tutorial for a simple one. 现在您可以找到许多这种变化,但是这里是一个简单的教程。

Tutorial 讲解

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将第二个导航栏放在第一个导航栏上...

http://www.bootply.com/118680 http://www.bootply.com/118680

#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.

相关问题 固定导航栏有两种不同的状态 - Fixed Navigation Bar with two different states 如何使用固定的引导程序导航栏显示不同的引导程序页面 - How to display different bootstrap pages with a bootstrap navigation bar fixed 如何在一个页面上有两个不同的变量? (JQuery的) - How can I have two of these on one page with different variables? (JQuery) 如何让两个不同的输入(一个用于移动设备,一个用于桌面设备)修改同一个变量? - How to have two different inputs (one for mobile, one for desktop) modify the same variable? 在一个导航栏中使用两种不同的单击动画 - using two different click animations in one nav bar jQuery飞出菜单-如何用行分隔两个不同的项目 - jQuery fly out menu - How to separate two different items with line JQuery UI Sortable - 如何在一个容器中对两种类型的项目进行排序 - JQuery UI Sortable - How to sort two types of items in one container 如何在同一表格上使用两种不同类型的日历? - How to have two different types of calendars on the same form? 使用CAML,如何将两个不同的列表项绑定到Sharepoint上的一个下拉列表? - Using CAML, how can I bind two different list items to the one dropdown list on Sharepoint? 一键两个不同的动作 - one button two different actions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM