简体   繁体   中英

Bootstrap Navbar Dropdown Mobile Issue

When my web design collapsed to mobile view, the dropdown menu doesn't push down the button below it, instead the menu shows up half way down the page. This only seems to happen on pages with the carousel function and lightbox2.

Any help would be appreciated.

I have tried this which was suggested in another topic:

.navbar-header {
position: relative;

z-index: 1; }

Here's the Navbar code:

    <nav>
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1" aria-expanded="false"><span class="glyphicon glyphicon-menu-hamburger"></span></button>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="defaultNavbar1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="index.html">Home<span class="sr-only">(current)</span></a></li>
        <li><a href="about.html">About Me</a></li>
        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Photography<span class="caret"></span></a>
          <ul class="dropdown-menu">
          <li><a href="events.html">Events</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="music.html">Music</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="nature.html">Nature</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="people.html">People</a></li>
          </ul>
        </li>
        <li><a href="construction.html">Contact Me</a></li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>

and the scripts at the bottom`

<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap-3.3.5.js" type="text/javascript"></script>
<script src="js/lightbox.js" type="application/javascript"></script>
<script>
    lightbox.option({
      'resizeDuration': 600,
      'wrapAround': true,
      'alwaysShowNavOnTouchDevices': true,
      'fitImagesInViewport': true
    })
</script>`

Fixed it.

I switched css files earlier on in the day and I didn't realise a .dropdown-menu was missing from the bootstrap css.

.navbar-nav .open .dropdown-menu

I would suggest you to try putting the script tags at top ins. it might work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM