错误的显示下拉菜单(移动)引导程序

时间:2016-01-23 01:08:08

标签: html css twitter-bootstrap mobile

我的问题在于这张照片: enter image description here

在移动视图上有与普通屏幕相同的下拉列表。

代码在这里:

<nav class="navbar navbar-default   box-centered" role="navigation">
  <div class="container-fluid menu-box">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">

        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">"logo here"</a>
    </div>


    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav nav-justified menu" style="margin:0 auto;">
              <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">List ext <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li class="text-padding"><a href="#">something</a></li>
            <li class="text-padding"><a href="#">other</a></li>
          </ul>
        </li>

        <li class="text-padding"><a href="#">Two</a></li>
        <li class="text-padding"><a href="#">Three</a></li>
        <li class="text-padding"><a href="#">Fouuur</a></li>


      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

我从样式表中获取这些元素的类: http://pastebin.com/HUUShLNQ

我希望菜单看起来像这样,每个元素都在前面: enter image description here 你能帮帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

检查这个小提琴: https://jsfiddle.net/1ummyodw/1/

您已从导航ul中删除了 navbar-nav 类,因此如果您添加此功能,则可以使用此更新HTML代码段:

    <nav class="navbar navbar-default   box-centered" role="navigation">
      <div class="container-fluid menu-box">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">

            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">"logo here"</a>
        </div>


        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav nav-justified menu" style="margin:0 auto;">
             <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">List ext <span class="caret"></span></a>
              <ul class="dropdown-menu text-center" role="menu">
                <li class="text-padding"><a href="#">something</a></li>
                <li class="text-padding"><a href="#">other</a></li>
              </ul>
            </li>

            <li class="text-padding"><a href="#">Two</a></li>
            <li class="text-padding"><a href="#">Three</a></li>
            <li class="text-padding"><a href="#">Fouuur</a></li>


          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>