Bootstrap NavBar汉堡菜单在移动设备上不起作用

时间:2018-11-15 03:26:23

标签: html css ruby-on-rails ruby twitter-bootstrap

当我在Mac上缩小窗口时,会出现汉堡菜单,但在移动设备上却没有。导航栏变得非常无格式。任何帮助将不胜感激。谢谢!

    <nav class="navbar navbar-inverse">
  <div class="container">
    <div class = "row">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
          <li><%= link_to "HomePage", listings_path %></li>
          <li><%= link_to "Reviews", reviews_path %> </li>
          <li><%= link_to "My Personal Listings", mylistings_path %></li>
          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Admin<span class="caret"></span></a>
              <ul class="dropdown-menu">
                <%if user_signed_in? && current_user.admin? %>
                  <li><%= link_to "Admin Page", users_path %></li>
                  <li><%= link_to "Add a Personal Listing", new_mylisting_path %></li>
                <%end%>
              </ul>
            </li>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Your Account <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                    <li><%= link_to 'Sign In', new_user_session_path %></li>
                    <li><%= link_to 'Sign Up', new_user_registration_path %></li>
                    <li><%= link_to('Sign Out', destroy_user_session_path, :method => :delete) %></li>
                  </ul>
                </li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Additional Resources<span class="caret"></span></a>
                  <ul class="dropdown-menu">
                    <li><%= link_to 'Zillow', "http://www.zillow.com/", :target => "_blank"%></li>
                    <li><%= link_to 'Realtor.com', "https://www.realtor.com/", :target => "_blank"%></li>
                    <li><%= link_to "Multiple Listing Service", "http://www.mls.com/", :target => "_blank"%></li>
                    <li><%= link_to 'Trulia', "https://www.trulia.com/", :target => "_blank"%></li>
                    <li><%= link_to 'Redfin', "https://www.redfin.com/", :target => "_blank"%></li>
                    </ul>
                    </li>
                  </ul>
          </div>
        </div>
      </div>
  </nav>

1 个答案:

答案 0 :(得分:0)

工作正常。您没有添加后两个图标栏。请参见下面的代码段或codepen

HtmlTextWriter