Bootstrap 3.3.7导航栏,带下拉菜单和子菜单

时间:2017-02-06 15:25:37

标签: twitter-bootstrap twitter-bootstrap-3

我要改变一个体面的网站来使用Bootstrap。在导航栏中,关于有2个下拉,Ahepa 215和AHEPA。在Ahepa 215上,我试图将兄弟作为一个子菜单加入其中。我必须忽略一些简单的事情。这是实时测试页面http://ahepa215.org/ahepamenu.html自定义css位于代码段框中。

/* Navbar */

#primary-navbar {
  background: #3193de;
  margin-bottom: 0;
}
/* we overwrite the default navbar style from Bootstrap */

nav.navbar {
  background: #3193de;
  font-size: 18px;
  border: 0;
  border-radius: 0;
  margin-bottom: 0;
  min-height: 34px;
}
/* The toggle unit (there is more stuff in there..) */

.navbar-header .navbar-toggle {
  border: 0;
}
.navbar-header .navbar-toggle span.icon-bar {
  background: #ffffff;
}
.navbar-header .navbar-toggle:hover span.icon-bar {
  background: #3193de;
}
/* The Logo/Start Button on mobile devices */

a.navbar-brand:link,
a.navbar-brand:visited {
  color: #ffffff;
}
a.navbar-brand:hover,
a.navbar-brand:focus {
  color: #c1c1c1;
}
/* First Level Main nav */

ul.nav {
  /* Menu style */
}
ul.nav li.active {
  background: #c1c1c1;
}
ul.nav li.active a:link,
ul.nav li.active a:visited {
  color: #666666;
}
ul.nav li a:link,
ul.nav li a:visited {
  color: #ffffff;
}
ul.nav li a:hover,
ul.nav li a:focus {
  color: #666666;
}
/* Our resposive dropdown */

ul.dropdown-menu {
  border-radius: 0;
  background: #3193de;
  width: 100%;
  margin: 0;
}
ul.dropdown-menu li a:link,
ul.dropdown-menu li a:visited {
  color: #ffffff;
  padding: 5px 15px;
}
ul.dropdown-menu li a:hover,
ul.dropdown-menu li a:focus {
  color: #666666;
}
.dropdown-submenu {
  position: relative;
}
.dropdown-submenu>.dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -6px;
  margin-left: -1px;
  - webkit-border-radius: 0 6px 6px 6px;
  -moz-border-radius: 0 6px 6px;
  border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
  display: block;
}
.dropdown-submenu>a:after {
  display: block;
  content: " ";
  float: right;
  width: 0;
  height: 0;
  border-color: transparent;
  border-style: solid;
  border-width: 5px 0 5px 5px;
  border-left-color: #ccc;
  margin-top: 5px;
  margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
  border-left-color: #fff;
}
.dropdown-submenu.pull-left {
  float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
  left: -100%;
  margin-left: 10px;
  -webkit-border-radius: 6px 0 6px 6px;
  -moz-border-radius: 6px 0 6px 6px;
  border-radius: 6px 0 6px 6px;
}
<div class="row main-navigation-container navbar-fixed-top" id="primary-navbar">
  <nav class="navbar">
    <div class="container-fluid">v
      <!-- Mobile Toggle Button and stuff -->
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#primary-navigation" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="AHEPA215" title="AHEPA 215">&nbsp; AHEPA 215</a>
      </div>
      <!-- End of mobile toggle button -->
      <!-- Start of the navbar -->
      <div class="collapse navbar-collapse" id="primary-navigation">
        <ul class="nav  nav-justified">
          <li><a href="index.html">Home<span class="sr-only">(current)</span></a>
          </li>

          <li><a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">About <b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="#">AHEPA</a>
              </li>
              <li class="dropdown-submenu">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">AHEPA 215</a>
                <ul class="dropdown-menu">
                  <li><a href="#">Brothers</a>
                  </li>
                </ul>
              </li>
            </ul>


            <li><a href="scholarship.html">Scholarships</a>
            </li>
            <li><a href="photos.html">Photos</a>
            </li>
            <li><a href="join.html">Join</a>
            </li>
            <li><a href="calendar.html">Calendar</a>
            </li>
            <li><a href="contact.html">Contact</a>
            </li>
        </ul>
      </div>
    </div>
  </nav>

</div>

1 个答案:

答案 0 :(得分:0)

添加此CSS或将nav-justified替换为navbar-nav类。

@media (max-width: 767px) {
  .nav.nav-justified .open .dropdown-menu {
    position: static;
    float: none;
    width: auto;
    margin-top: 0;
    background-color: transparent;
    border: 0;
    -webkit-box-shadow: none;
            box-shadow: none;
  }
}