【问题标题】:is there an error i am not spotting on the dropdown?我在下拉列表中没有发现错误吗?
【发布时间】:2020-10-28 17:37:53
【问题描述】:

我正在尝试显示此下拉菜单,但单击任何内容时它不会下拉。我已经安装了 twitter bootrap gem...请指教。我试过玩宝石,但什么也没发生。我什至从 bootstrap.com 复制了一个 nav 代码 sn-p 的示例,但什么也没发生。

<nav class="navbar navbar-expand-lg navbar-transparent navbar-fixed-top " >
  <div class="container">
    <%= link_to "Recipes",root_path, class: "bt  btn-lg btn-success" ,id:"logo"%>
    <div class="nav_item">
        <%= link_to "Edit Profile",edit_user_registration_path, class:" btn btn-default btn-warning", style: 'margin-top: 10px;' %> 
    </div>
    

     <div class="nav_item">
        <%= link_to "Link one","", class:" btn btn-default btn-warning", style: 'margin-top: 10px;' %>
    </div>
     <div class="nav_item">
        <%= link_to "Link one","", class: "btn btn-default btn-warning", style: 'margin-top: 10px;' %>
    </div>
     <div class="nav_item">
        <%= link_to "New Recipe",new_recipe_path, class: "btn btn-default btn-warning", style: 'margin-top: 10px;' %>
    </div>
    <ul class= "nav_item">
      <li class= "dropdown">    
        <%= link_to '#', class:'btn btn-default btn-danger dropdown-toggle', 'data-toggle'=>'dropdown' do%>
            <%=current_user.name%><b class='caret'></b >
        <%end %>
        <ul class= 'dropdown-menu'>
          <li ><%= link_to "View profile", user_show_path(current_user)%></li>
          <li ><%= link_to "Edit profile", edit_user_registration_path %></li>
          <li class= 'divider'></li>
          <li ><%= link_to "New Recipe", new_recipe_path %></li>
          <li class= 'divider'></li>
          <li ><%= button_to "Log Out ", destroy_user_session_path %></li>
        </ul>
      </li>
    </ul>
  </div>
</nav>


  

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap


    【解决方案1】:

    您应该再次更好地查看 Bootstrap 文档。

    如果您使用的是 v4:https://getbootstrap.com/docs/4.0/components/navbar/

    我认为您的课程有点偏离,例如nav_item 应该是nav-item,您还缺少一个围绕您的&lt;li&gt; nav-item 标签的无组织列表navbar-navnav-item dropdown如果您想要下拉等.. 我看到你的代码中有很多不正确的地方。

    我也会避免在导航栏中使用容器 div。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-15
      • 2019-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-04
      • 1970-01-01
      • 2021-04-12
      相关资源
      最近更新 更多