我有一个带有几个下拉菜单的导航栏。切换功能正常,导航栏在较小的屏幕上折叠,除下拉列表中的链接外,其他所有功能均可用。谁能看到这是怎么回事?另外,我拥有的任何其他类仅用于着色。我没有在此处包括CSS,因为我认为这与问题无关。
<!-- header -->
<header>
<!-- navbar -->
<nav class="navbar navbar-expand-md fixed-top nav-menu navbar-top-image">
<%= link_to root_path do %>
<%= image_tag 'yarnn-text-logo.png', width: 120, alt: 'Yarnn icon', id: "logo" %>
<% end %>
<button class="navbar-toggler bg-dark" type="button" data-toggle="collapse" data-target="#myNavbar">
<span class="navbar-toggler-icon mt-2">
<i class="fa fa-navicon text-danger"></i>
</span>
</button>
<div class="collapse navbar-collapse justify-content-end text-uppercase scrollable" id="myNavbar">
<ul class="navbar-nav">
<% if user_signed_in? %>
<li class="nav-item dropdown" data-toggle="dropdown" data-target="#dashboard_drop"><a class="nav-link text-light m-2 dropdown-toggle" href="#">
<i class="fas fa-cog text-light mr-2"></i><%= current_user.username %></a>
<div class="dropdown-menu p-2" id="dashboard_drop">
<%= link_to "Dashboard", dashboard_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Profile", user_path(current_user), :class => "dropdown-item navdrop-link" %>
<%= link_to "Edit Account", edit_registration_path(current_user), :class => "dropdown-item navdrop-link" %>
<div class="dropdown-divider"></div>
<%= link_to "My Station", station_path(current_user), :class => "dropdown-item navdrop-link" %>
<%= link_to "My Downloads", purchases_path, :class => "dropdown-item navdrop-link" %>
<div class="dropdown-divider"></div>
<%= link_to "Upload Track", new_track_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Create Album", new_album_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Create Blog Post", new_blog_path, :class => "dropdown-item navdrop-link" %>
<div class="dropdown-divider"></div>
<!--- Seller Stuff --->
<% if current_user.uid? %>
<%= link_to "Sell Something", new_listing_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Sales", sales_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Payout", payout_method_path, :class => "dropdown-item navdrop-link" %>
<% else %>
<%= link_to "Become a Seller", payout_method_path, :class => "dropdown-item navdrop-link" %>
<% end %>
<div class="dropdown-divider"></div>
<%= link_to destroy_user_session_path, method: :delete, :class => "dropdown-item navdrop-link current" do %>
<i class="fas fa-sign-out-alt text-dark fa-lg"></i> Log Out
<% end %>
</div>
</li>
<li class="nav-item">
<%= link_to notifications_path(current_user), :class => "nav-link text-light m-2" do %>
<i class="fas fa-comments text-light mr-1"></i>
<% if @notifications.count > 0 %>
<span class="site-blue"><%= @notifications.count %></span>
<% end %>
<% end %>
</li>
<li class="nav-item dropdown" data-toggle="dropdown" data-target="#nav_explore"><a class="nav-link text-light m-2 dropdown-toggle" href="#">
<i class="fas fa-map-signs text-light"></i> Explore</a>
<div class="dropdown-menu p-2" id="nav_explore">
<%= link_to "Albums", albums_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Tracks", tracks_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Genres", genres_path, :class => "dropdown-item navdrop-link" %>
<%= link_to "Blog Posts", blogs_path, :class => "dropdown-item navdrop-link" %>
</div>
</li>
<li class="nav-item">
<%= link_to listings_path, :class => "nav-link text-light m-2 menu-item" do %>
<i class="fas fa-shopping-cart text-light"></i> Marketplace
<% end %>
</li>
<%= link_to destroy_user_session_path, method: :delete, :class => "nav-link text-light m-2 menu-item" do %>
<i class="fas fa-sign-out-alt site-red fa-lg"></i>
<% end %>
<% end %>
</ul>
</div>
</nav>
<!-- end of navbar -->
</header>
<!-- end of header -->
答案 0 :(得分:0)
我可以使用它,但是这次必须使用Bootstrap文档中的按钮来完全重建功能。我认为功能是重要的部分,以后可以根据自己的喜好对其进行样式设置。这也是我完整的导航栏,我早些时候省略了一些无关紧要的元素以使其不那么密集。
<!-- header -->
<header>
<!-- navbar -->
<nav class="navbar navbar-expand-md fixed-top nav-menu navbar-top-image">
<%= link_to root_path do %>
<%= image_tag 'yarnn-text-logo.png', width: 120, alt: 'Yarnn icon', id: "logo" %>
<% end %>
<button class="navbar-toggler bg-dark" type="button" data-toggle="collapse" data-target="#myNavbar">
<span class="navbar-toggler-icon mt-2">
<i class="fa fa-navicon text-danger"></i>
</span>
</button>
<div class="collapse navbar-collapse justify-content-end text-uppercase scrollable" id="myNavbar">
<ul class="navbar-nav">
<% unless user_signed_in? %>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle m-2" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
EXPLORE
<span class="caret"></span>
</button>
<ul class="dropdown-menu p-2" aria-labelledby="dropdownMenu1">
<li class="dropdown-item navdrop-link"><%= link_to "Albums", albums_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Tracks", tracks_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Genres", genres_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Blog Posts", blogs_path %></li>
</ul>
</div>
<li class="nav-item">
<%= link_to listings_path, :class => "nav-link text-light m-2 menu-item" do %>
<i class="fas fa-shopping-cart text-light"></i> Marketplace
<% end %>
</li>
<li class="nav-item">
<%= link_to "Login", new_user_session_path, :class => "nav-link text-light m-2 menu-item" %>
</li>
<li class="nav-item">
<%= link_to "Register", new_user_registration_path, :class => "nav-link text-light m-2 menu-item" %>
</li>
<% else %>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle m-2" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fas fa-cog text-light mr-2"></i><%= current_user.username %>
<span class="caret"></span>
</button>
<ul class="dropdown-menu p-2" aria-labelledby="dropdownMenu1">
<li class="dropdown-item navdrop-link"><%= link_to "Dashboard", dashboard_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Profile", user_path(current_user) %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Edit Account", edit_registration_path(current_user) %></li>
<div class="dropdown-divider"></div>
<li class="dropdown-item navdrop-link"><%= link_to "My Station", station_path(current_user) %></li>
<li class="dropdown-item navdrop-link"><%= link_to "My Downloads", purchases_path %></li>
<div class="dropdown-divider"></div>
<li class="dropdown-item navdrop-link"><%= link_to "Upload Track", new_track_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Create Album", new_album_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Create Blog Post", new_blog_path %></li>
<div class="dropdown-divider"></div>
<!--- Seller Stuff --->
<% if current_user.uid? %>
<li class="dropdown-item navdrop-link"><%= link_to "Sell Something", new_listing_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Sales", sales_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Payout", payout_method_path %></li>
<% else %>
<li class="dropdown-item navdrop-link"><%= link_to "Become a Seller", payout_method_path %></li>
<% end %>
<div class="dropdown-divider"></div>
<li class="dropdown-item navdrop-link current"><%= link_to destroy_user_session_path, method: :delete do %>
<i class="fas fa-sign-out-alt text-dark fa-lg"></i> Log Out
<% end %></li>
</ul>
</div>
<li class="nav-item">
<%= link_to notifications_path(current_user), :class => "nav-link text-light m-2" do %>
<i class="fas fa-comments text-light mr-1"></i>
<% if @notifications.count > 0 %>
<span class="site-blue"><%= @notifications.count %></span>
<% end %>
<% end %>
</li>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle m-2" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
EXPLORE
<span class="caret"></span>
</button>
<ul class="dropdown-menu p-2" aria-labelledby="dropdownMenu1">
<li class="dropdown-item navdrop-link"><%= link_to "Albums", albums_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Tracks", tracks_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Genres", genres_path %></li>
<li class="dropdown-item navdrop-link"><%= link_to "Blog Posts", blogs_path %></li>
</ul>
</div>
<li class="nav-item">
<%= link_to listings_path, :class => "nav-link text-light m-2 menu-item" do %>
<i class="fas fa-shopping-cart text-light"></i> Marketplace
<% end %>
</li>
<%= link_to destroy_user_session_path, method: :delete, :class => "nav-link text-light m-2 menu-item" do %>
<i class="fas fa-sign-out-alt site-red fa-lg"></i>
<% end %>
<% end %>
</ul>
</div>
</nav>
<!-- end of navbar -->
</header>
<!-- end of header -->