简体   繁体   English

Bootstrap Navbar Dropdown Mobile问题

[英]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. 这仅发生在具有轮播功能和lightbox2的页面上。

Any help would be appreciated. 任何帮助,将不胜感激。

I have tried this which was suggested in another topic: 我尝试了另一个主题中建议的方法:

.navbar-header {
position: relative;

z-index: 1; z索引:1; } }

Here's the Navbar code: 这是Navbar代码:

    <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. 我当天早些时候切换了CSS文件,但我没有意识到引导CSS缺少.dropdown菜单。

.navbar-nav .open .dropdown-menu

I would suggest you to try putting the script tags at top ins. 我建议您尝试将脚本标签放在顶部。 it might work. 它可能会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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