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

Adding a class to a Vue component using the $refs property

I am facing an issue where I need to add dynamic class names to various Vue components based on their reference names listed in a configuration file. Manually adding classes to each component is not feasible due to the large number of components. To addre ...

Redirecting a WordPress file's URL

I'm currently developing a WordPress plugin that allows setting an expiration date for uploaded files. Once the file expires, users will be redirected to a page informing them that the file is no longer accessible. For instance: An administrator up ...

Synchronization issue between CSS style and Javascript is causing discrepancies

I am looking to avoid using jquery for simplicity. I have three websites that each page cycles through. My goal is to scale the webpages by different values. I attempted applying a class to each page and used a switch statement to zoom 2x on Google, 4x o ...

Display the icon beneath the list item label

How can I display the ion-edit icon below the list names? The icons are currently appearing on the right side of each list name, but I want them to be aligned below with some spacing. When clicking on "Data Source Connections," a sublist will be shown whe ...

using mathematical calculations to determine opacity levels in a set of rules

I'm attempting to multiply opacity values. I have experimented with the following: calc(@opacity * 100) @opacity-ruleset { filter:alpha(opacity= (@opacity * 100)); -moz-opacity:@opacity; opacity: @opacity; -webkit-opacity: @opacity; } Is there a wa ...

The function of style.marginRight differs from that of style.marginLeft

One function aligns content to the left while the other doesn't align it to the right function openNavLeft() { document.getElementById("mySidenavLeft").style.width = "100vw"; document.getElementById("main").style.marginLeft = "100vw"; } function ...

The filter and status parameters are not functioning properly on the customer/{id}/orders endpoint

I am currently utilizing the WooCommerce Rest API to retrieve data within an Android application. My objective is to retrieve a list of customer orders based on specific statuses: pending, processing, or on-hold. Although I have used the 'status&apo ...

What is the best way to adjust a fixed-width table to completely fill the width of a smartphone browser?

In an ancient web application, the design was primarily constructed using rigid tables: <div class="main"> <table width="520" border="0" cellspacing="0" cellpadding="0"> <tr> <td>...</td> </ ...

Unusual CSS hierarchy observed post AJAX content load

Currently, I am facing a puzzling issue where my CSS rules seem to be losing precedence on a page loaded via AJAX. Despite placing my custom CSS file last in the main page, allowing it to take precedence over any bootstrap styles, after loading new content ...

Adjusting cell width based on content in CSS to handle overflows automatically

I am facing a challenge with a table that has varying widths of content in each cell. I need the lengthy content to be displayed next to nowrap and overflow. After trying the solution mentioned here, all cells ended up with the same width. However, I requ ...

The JQuery(document).ready function does not seem to be executing on the webpage, but it works as expected when placed in a

I have encountered a peculiar problem. It's strange to me because I can't figure out the root cause of it, despite trying everything in the Chrome Developer Tools debugger. Here is a snippet of code that works when I run it from a file on my desk ...

Establishing a class for wp_nav_menu

Is there a way to transform the following code: <ul class="ulStyle"> <li class="liStyle"> <div class="first"> <div class="second"> menu1 </div> </div> </li> </ul> into wp_nav_menu? I'm struggling with ...

Issue with migrating a Wordpress + AngularJS site: displaying the $domain variable instead of the correct domain/IP address

Greetings to all in these unusual and uncertain times. I trust everyone is keeping well and safe. Despite my limited knowledge of Wordpress and zero experience with AngularJS, I recently undertook the task of migrating a Wordpress site from a failing serv ...

Using Java beans to present form data utilizing session

How can I utilize Java Beans and session beans to store user input data and display a preview of the entered details on the next page? I have already created a servlet using JSP, but now I want to incorporate Java Beans to showcase the form data. How shoul ...

Do CSS Stylesheets load asynchronously?

Is there a difference in how stylesheets are loaded via the link tag - asynchronously or synchronously? In my design, I have two stylesheets: mura.css and typography.css. They are loaded within the head section of the page, with typography.css being load ...

Trouble organizing a collection of destinations based on their geolocation and proximity

To address this issue, my approach has been to feed variables into the value attributes of an option list and then sort it based on these values. When manually assigning values, everything works smoothly, for example: <option id="link1" value="1">A& ...

WordPress Query Rewriting - Eliminate query parameters on specific custom pages

After creating a custom page in Wordpress that displays different data based on the query string, I noticed an issue with how search engines and tracking software interpret the URL. Currently, my query string looks like: http://example.com/extcat/?uid=15& ...

Place the label and input elements next to each other within the form-group

My form group includes both a label and an input field <div class="col-md-12 form-group"> <label class="col-sm-2 col-form-label" for="name">Name</label> <input type="text" class="form-control" name="name" id="name" [(ngMode ...

How can you update the background image of a particular div using the 'onclick' feature in React.JS?

Thank you for helping me out here. I'm currently working with ReactJS and facing a challenge where I need to change the background of a div from a color to a specific image URL upon clicking a button in a modal. Despite my efforts, I keep encountering ...

The issue with the page width is occurring due to a bug related to the

When pages contain the AddThis code, they tend to become very wide due to the code itself, resulting in a horizontal scroll bar appearing. However, by removing the code or changing the page direction to LTR, the issue is resolved and the page width return ...