Utilize Bootstrap to create two navigation bars, where the secondary bar overlaps the dropdown of the

I am encountering an issue with my Rails app where I have two Bootstrap navigation bars. The primary bar includes a dropdown for user actions like sign-out and user profile, but it is being overlapped by the secondary bar.

Additionally, when I decrease the size of the viewport, the secondary bar collapses as expected, but the actions from the primary bar do not appear in the collapsed menu. How can I address this problem?

This is a snippet of my navbar code:

<nav role="navigation" class="navbar navbar-fixed-top firstnavbar">
      <div class="container">
          <div class="navbar-header">
              <a class="navbar-brand" rel="home" href="#" title="Sickbubble">
              <%= link_to(image_tag("cropped-sickbubble-logo-beta-3"),root_path) %>
              </a>
          </div>
          <div class="collapse navbar-collapse">
              <ul class="nav navbar-nav navbar-right">
                <% if user_signed_in? %>
                  <div class="dropdown">
                    <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"><%= image_tag current_user.profile_image %> <%= "#{current_user.name}" %>
                    <span class="caret"></span></button>
                    <ul class="dropdown-menu">
                      <li><a href="#">HTML</a></li>
                      <li><a href="#">CSS</a></li>
                      <li><%= link_to 'Log out', destroy_user_session_path, method: :delete %></li>
                    </ul>
                  </div>
                <% else %>
                  <li><%= link_to 'Log In', new_user_session_path %></li>
                  <li><%= link_to 'Register', new_user_registration_path %></li>
                <% end %>
              </ul>
          </div>
      </div>
  </nav>
  <nav role="navigation" class="navbar navbar-default navbar-fixed-top secondnavbar">
    <div class="container">
      <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
      </button>
      <div id="navbarCollapse" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
              <li><%= link_to "Categories", root_path %></li>
              <li><%= link_to "Businesses", businesses_path %></li>
              <li><%= link_to "Near me", geolocation_path, "data-no-turbolink": true %></li>
          </ul>
      </div>
    </div>
  </nav>

Here is some custom CSS that may be relevant to the issue:

.firstnavbar {
  background-color: #282828;
  border-radius: 0px;
  border: 0px;
  min-height:53px;
  color: #ffffff;
  margin-bottom: 0px;
  ul.nav.navbar-nav, li  {
    font-weight: 400;
    a {
      color: #FFFFFF;
      background-color: #282828;
    }
    a:hover {
      background-color: #EEEEEE;
      color: #282828;
    }
  }
}

.secondnavbar
 {
    background-color: #FFFFFF;
     top: 50px;
     ul.nav.navbar-nav, li  {
       font-weight: 400;
       a {
         color: #282828;
         background-color: #FFFFFF;
       }
       a:hover {
         background-color: #EEEEEE;
       }
     }
 }

Image showing overlap: https://i.sstatic.net/X8kOS.png

Image showing responsive menu bar not displaying logout option: https://i.sstatic.net/bPMf6.png

Answer №1

To change the z-index of the secondary navigation bar so that it appears below the main navigation bar, you can adjust the CSS code as follows:

.secondary-nav {
  z-index: 990;
}

Answer №2

One method you could try is enclosing the navbars within

<div class="row"></div>
. I find this approach effective for styling the navbars.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Disabling the :focus state on a link when the modal window is closed

I am looking to remove the :focus state from links that trigger a modal window once the modal is closed. Currently, in Bootstrap, the link retains focus until the user clicks elsewhere on the page. I have attempted the following code: $('.modal' ...

transfer text from one input field to all others

Here is my customized form <form id=form1 method=post accept-charset=UTF-8 action=> <input type=hidden name=video_id[0] value=K94KNsN43BU><p>Title<br> <textarea rows=1 cols=40 id=title_0 name=title[0]>custom title ...

Innovative dropdown menu featuring images and informative text snippets

I have a question about creating a menu similar to the one on http://www.resellerclub.com that includes images and text details. Are there any ideas on which technologies were used or if there are any commercial solutions available for this? Thank you. ...

Highlight the active menu item using jQuery

Check out my menu example here: http://jsfiddle.net/hu5x3hL1/3/ Here is the HTML code: <ul id="menu" class="sidebar"> <li> <a href="#" class="clickme">Menu</a> <ul id="menu1"> <li><a class="dropdown-clas ...

The Angular/Bootstrap Modal is not functioning properly: TypeError occurs due to v2.deleteModalProject not being recognized as a function and

My main objective is to allow users to call the modal multiple times for content deletion. However, I encountered issues when the modal was triggered a second time without reloading the page. I am currently working with Angular version 1.5.6 After spendi ...

The concept of functions in JavaScript: fact or fiction?

Is there a way to show the message "Yes" or "No" based on the return value of a function without directly using the words true and false, and without utilizing alert? Any suggestions would be greatly appreciated. Thank you. function myFunction { if (Ma ...

Include a Footer on the HTML Document

Having an issue with the placement of my footer in a web application. I've managed to generate XML data to render the HTML page and everything displays correctly except for the footer. The footer is supposed to be at the bottom of the page but it&apos ...

Tips on updating CSS styles for navigation bar links in real time

Currently, my homepage displays a CSS content hover effect when the user interacts with the icons. However, I am facing an issue where all icons show the same text "home" on hover. How can I customize the text output for each individual icon/link? Your hel ...

Issues arise with AJAX authentication request

Currently, I'm working on incorporating a basic login form with an AJAX request that forwards the user to a page for querying my database. Depending on the results, the user is then redirected to the main index page or prompted back to the login form. ...

Tips for extracting data from a table's options:

Can someone help me with this HTML table issue? In columns col6 and col7, I have select elements that store different options. What I'm trying to do is retrieve all the data from the table based on the options selected in columns col6 and col7. Howev ...

How can I determine if a user has reached the end of a non-scrollable div by utilizing HostListener and directives within Angular?

In my Angular project, I have designed a main layout using flex display with specific height and overflow settings. The main content div inside this layout has its own unique styling to ensure consistent appearance for any components inserted within it. By ...

When enclosing my Javascript code in CDATA tags within my SVG files, it does not execute

Having an SVG file in this format: <svg id="test" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" viewBox="0 0 1435 1084"> &l ...

`Heart-shaped loading bar in Reactjs`

Looking for help in creating a heart-shaped progress loader for a React project. I attempted using CSS but encountered issues with the progress not filling the entire heart design. Below is the code snippet I used. The progress should start from the bottom ...

Trouble with sending input through Ajax in HTML form

I'm facing a dilemma that I can't solve. The issue arises from a page (index.php) that begins by opening a form, then includes another PHP page (indexsearch.php), and finally closes the form. The included page works with a script that displays d ...

Turn off automatic compilation for LESS styling

In my Eclipse environment, I am looking to have LESS compile only when explicitly triggered by mvn package. Currently, any changes made in my less file immediately update the CSS. How can I prevent this automatic behavior? <plugin> <groupId> ...

Guide to utilizing custom fonts in a VUE application

I'm currently working on my first Vue project and despite following various examples and the official documentation, I am struggling to resolve an issue regarding importing fonts locally in my project. https://i.sstatic.net/mXryH.png Within my `` tag ...

Once more baffled by the nested boxes, this iteration adorned in vibrant hues and trimmed with a striking border

In a previous inquiry, I sought advice on centering one box within another. However, my attempts this time around have led to some peculiar results. I experimented with two different code variations- one involving a background color and the other utilizing ...

Obtaining the selected value from multiple dropdown menus by clicking a button in Angular 6

Looking for help with getting the selected values from 2 dropdowns in Angular 6 or Typescript? Check out my code below and let me know if you can assist! app.component.html <select class="select1"> <option>country1</option> &l ...

CSS3: What is causing this issue in FireFox?

http://jsfiddle.net/tNg2B/ It's clear that there is a noticeable difference when viewing this in Chrome compared to Firefox. The ":before" and ":after" pseudo classes seem to be malfunctioning in Firefox. Is there a way to resolve this issue? Edit: ...

A guide to accessing the sibling of each selector with jQuery

Imagine you have the following HTML structure: <div class="parent"> <div class="child"></div> <div class="sibling">content...</div> </div> <div class="parent"> <div class="child"></div> <div ...