中的多个固定顶部导航栏标题

中的多个固定顶部导航栏标题

本文介绍了Twitter Bootstrap 3 中的多个固定顶部导航栏标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 引导程序 3.02

我希望将 2 个固定到顶部导航栏上,类似于 Joomla!3 实现他们的浏览屏幕.

然后一旦你滚动导航栏 #2 与顶部的对接:

我看过:

但是尝试多个片段我无法让它工作.任何人都可以帮助在 jsFiddle 中进行工作演示吗?

解决方案

下面的代码是一个基本的开始使用两个 navbarsaffix.

HTML

<div class="容器"><div class="navbar-header"><a class="navbar-brand" href="#">Brand</a>

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><ul class="nav navbar-nav"><li class="下拉菜单"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a><ul class="下拉菜单"><li><a href="#">动作</a></li><li><a href="#">另一个动作</a></li><li><a href="#">这里还有别的东西</a></li><li class="divider"></li><li><a href="#">分隔链接</a></li><li class="divider"></li><li><a href="#">一个单独的链接</a></li><li class="下拉菜单"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a><ul class="下拉菜单"><li><a href="#">动作</a></li><li><a href="#">另一个动作</a></li><li><a href="#">这里还有别的东西</a></li><li class="divider"></li><li><a href="#">分隔链接</a></li><li class="divider"></li><li><a href="#">一个单独的链接</a></li>

</div><!--/.container-fluid --></nav><div class="divide-nav"><div class="容器"><p class="divide-text">这里有一些文本

<nav class="navbar navbar-default navbar-lower" role="navigation"><div class="容器"><div class="collapse navbar-collapse collapse-buttons"><form class="navbar-form navbar-left" role="search"><button class="btn btn-success">Button</button><button class="btn btn-default">Button</button><button class="btn btn-default">Button</button><button class="btn btn-default">Button</button></表单>

</nav><div class="容器"><div class="row"><div class="filler"></div>

CSS

body{边距顶部:50px;}.divide-nav{高度:50px;背景颜色:#428bca;}.divide-text{颜色:#fff;行高:20px;字体大小:20px;填充:15px 0;}.附加{顶部:50px;宽度:100%;}.填料{最小高度:2000px;}.navbar-form {填充左:0;}.navbar-collapse{填充左:0;}

JavaScript

$('.navbar-lower').词缀({偏移量:{顶部:50}});

I would like to have 2 fixed to top navbars similair to how Joomla! 3 implements their browse screen.

And then once you scroll navbar #2 butts up against the top one:

I have looked at:

but trying multiple snippets I cannot get this to work. Can anyone help with a working demo in jsFiddle?

解决方案

The code below is a basic start using two navbars and affix.

HTML

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">Brand</a>
    </div>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
    </div>
  </div><!-- /.container-fluid -->
</nav>
<div class="divide-nav">
  <div class="container">
    <p class="divide-text">Some Text Here</p>
  </div>
</div>
<nav class="navbar navbar-default navbar-lower" role="navigation">
  <div class="container">
    <div class="collapse navbar-collapse collapse-buttons">
      <form class="navbar-form navbar-left" role="search">
        <button class="btn btn-success">Button</button>
        <button class="btn btn-default">Button</button>
        <button class="btn btn-default">Button</button>
        <button class="btn btn-default">Button</button>
      </form>
    </div>
  </div>
</nav>
<div class="container">
  <div class="row">
    <div class="filler"></div>
  </div>
</div>

CSS

body{
  margin-top: 50px;
}

.divide-nav{
  height: 50px;
  background-color: #428bca;
}

.divide-text{
    color:#fff;
    line-height: 20px;
    font-size:20px;
    padding: 15px 0;
}

.affix {
  top: 50px;
  width:100%;
}

.filler{
  min-height: 2000px;
}

.navbar-form {
   padding-left: 0;
}

.navbar-collapse{
   padding-left:0;
}

JavaScript

$('.navbar-lower').affix({
  offset: {top: 50}
});

这篇关于Twitter Bootstrap 3 中的多个固定顶部导航栏标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 03:58