The horizontal layout for the Bootstrap 3 sub menu is not displaying beneath the dropdown as expected

Check out my testing site here.

I envision the navigation of my website to look like this in the near future, albeit at a lower resolution.

While experimenting with the inspector tool, I noticed that changing the display property to inline-block causes the submenu to shift up and to the left. It also fails to display inline as intended.

Although using display: inline-flex helps me achieve an inline layout, it still results in the submenu moving up and to the left.

The current setup employs wp_nav_menu for displaying the navbar, allowing easy management through wpadmin. Here is the HTML code:

<div class="navbar navbar-static" role="navigation">
  <div class=""> <!-- This used to have container. -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <div class="navbar-collapse collapse">

      <!-- Menu setup goes here -->
    <?php
      $args = array(
          'menu'  => 'header_menu',
          'menu_class'  => 'nav navbar-nav nav-justified',
          'menu_id' =>  'test',
          'container'  => 'false',
          'before' => '',
          'link_after' => ''

        );
      wp_nav_menu( $args );
    ?>

    </div><!--/.navbar-collapse -->
  </div>
</div>

Here is the corresponding CSS for the Navbar:

/***********************************/
/* Hover effects on nav display */
/***********************************/
.navbar-nav.nav-justified > li{
    float:none;
}
.admin-bar .navbar-fixed-top {
    margin-top: 32px;
}
.navbar-toggle .icon-bar {
    background-color: #fff;
}

.navbar-toggle {
    background-color: #550015;
    float: left;
    margin-left: 15px;

}

/*Dropdown nav items*/
@media (min-width:768px) {
    .sub-menu {
        display: none;
        position: absolute;
        background: white;
        padding: 10px 15px;
        width: 200px;       
    }

    li:hover .sub-menu {
        display: block;
    }
    .nav>li>a {
        /*padding: 10px 70px;*/
        color: black;
    }

}


/*On hover color change*/
.nav>li>a:hover, .nav>li>a:focus {
    background-color: transparent;
}

.sub-menu li {
    margin-bottom: 10px;
    list-style: none;
}

.sub-menu li:last-child {
    margin-bottom: 0;
}

.sub-menu a  {
    color: #000;
}

/*Hover link effects*/
.sub-menu a:hover  {
    color: #000;
    text-decoration: none;  
}   

.current-menu-item > a, .current-menu-parent > a {
    background: transparent;    
}
.current-menu-parent li a {
    background: inherit;
}

/*Hover effects for main menu*/
.nav-justified a:after {
  clear: both;
  display: block;
  content: "";
  position: relative;
  width: 0;
  left: 50%;
  height: 2px;
  background: rgba(0, 0, 0, 0.56);
  -webkit-transition: width 0.2s, left 0.2s;
  -moz-transition: width 0.2s, left 0.2s;
  -o-transition: width 0.2s, left 0.2s;
  transition: width 0.2s, left 0.2s;
  border-radius: 1px;
}
.nav-justified a:hover:after, .nav-secondary a:focus:after {
  width: 100%;
  left: 0;
}

Answer №1

Revise

.sub-menu:hover {
    visibility: visible;
}

into

.sub-menu:hover {
    visibility: hidden;
}

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

When the 'Show More' button is clicked, one Div will smoothly slide over another Div

I've been struggling for hours to find a way to make one DIV slide over another DIV below it instead of pushing it down. The setup is quite straightforward. I have a script that reveals more text when the 'Show More' button is clicked. Desp ...

Placing an image at the forefront of all elements

Recently, I created a horizontal opt-in bar for my Newsletter on my website. Instead of the traditional submit button, I decided to use an image by incorporating some CSS: #mc_embed_signup input.button { background: url(http://urltotheimg.com/image.jpg); ...

Tips for creating floating and right-aligned notifications using CSS in Vue.js

Struggling to position my basic notification component in the top right corner. Here is my HTML: <div class="notifications"> <p>{{ notification.message }}</p> </div> This is my notifications class: .notifications { position: ...

Traversing JSON Data using Vanilla JavaScript to dynamically fill a specified amount of articles in an HTML page

Here is the code along with my explanation and questions: I'm utilizing myjson.com to create 12 'results'. These results represent 12 clients, each with different sets of data. For instance, Client 1: First Name - James, Address - 1234 Ma ...

How can you modify the JSON response when using JWT Authentication with WP-API?

I recently implemented the "JWT Authentication for WP-API" plugin to handle logins and token generation on my website. After logging in, I noticed that the JSON response only includes data from the wp_users table. Is there a way to modify the response to ...

The issue of webkit animation rotation malfunctioning on Nexus Mobile devices

I'm currently working on developing a double ring radar animation within an Ionic hybrid application. The animation functions perfectly when viewed in a web browser, however, I've encountered issues when attempting to run it on the Nexus mobile ...

Div controls the margins of all other elements

I am encountering an issue when trying to position #slider, where the navigation and elements above it also move. It seems as though they are contained within #slider, even though they are not. HTML: <div id="slider" class="clearfix"> <d ...

Adapting Bootstrap components based on the screen size: Viewport-driven

Check out our Custom Sizing Solution, designed to offer sizing options tailored to different devices and viewports. Here's what we can do: For small devices, the width will be set at 100% For larger devices, the width will be adjusted to 75% For ext ...

When I hover my mouse over the items on the Navigation bar, they shift forward

Seeking assistance with a coding issue. When hovering over TOYOTA, the HONDA and CONTACT US sections move forward unexpectedly. This movement is unwanted as I would like only the next list item to display when hovering over TOYOTA and HONDA. How can I corr ...

Connecting CSS and JS files in JSP was a bit of a challenge

Just starting out with jsp and using Glassfish server via netbeans. Struggling to link my jsp file with css and javascripts. Below is the structure of my files: Web Pages --Web-Inf --assets --css --style.css --js --jquery.js ...

Internet Explorer fails to execute CSS or jQuery commands

Apologies in advance for posing a question that may not be specific or beneficial to the wider community. Currently, my main focus is resolving this issue for my own peace of mind. In the process of designing a website, I implemented a social drawer featu ...

Shift all content to the right when viewing on mobile devices

I'm looking to create space for a menu on the left side, similar to the one on Mashable's mobile view. How can I move all the content to the right? Feel free to resize the window and compare with . Thank you. Best regards, Marius ...

Slanted lines HTML CSS

I am encountering an issue with my HTML and CSS coding. The design requires a zig-zag "border" at the top and bottom of the page, creating a white paper space in between. The paper needs to be positioned underneath the zig-zag borders. Currently, this is ...

a graphical representation of data organized in tabular form using

I am trying to develop a game where I need to generate a map using PHP. The goal is to create 100 table boxes in a specific pattern, but so far my attempts have not been successful... $field = 100; echo "<table border='3px' dir='ltr&apos ...

Change the background color on hover without affecting the text color

I am having some trouble with my code. I can only change the color of the "popup1_btn" button when hovering, but the text color remains the same. If I use .popup1_btn a:hover, it only changes the background and text color of the text, not the entire button ...

Tips for integrating tooltips in a dynamic highcharts chart

This image shows the desired final output View Highcharts here and I am looking to merge the date and stock value in a single tooltip, how can this be achieved? highcharts ...

Determine the position of an element in relation to a specific ancestor using JavaScript

Let's consider the following example of HTML code: <div id="site_header_container" class="site_bar_container"> <div id="site_header"> <div id="header_logo_container"> <a class="sliced" id="header_ ...

Creating Consistent Button Padding in Material UI

I am working with a series of Material UI buttons that are defined as follows: <Button className={classes.button}>Edit</Button> <Button className={classes.button}>Duplicate</Button> <hr /> <Button c ...

AngularJS makes it easy to retrieve data from a server using the $

I am interested in using Bootstrap datatable with AngularJS. Here is the code I have been working on: https://codepen.io/bafu2203/pen/VzBVmy Upon inspection, you will notice that when attempting to populate the table with data from a $http.get call, the t ...

How can I modify the appearance of a slider's range?

I'm struggling with customizing the style of a price slider input range. No matter what I do, the changes don't seem to take effect. Can anyone pinpoint where I may be going wrong? Appreciate any guidance on this! Thank you! <div class=" ...