The secondary menu appears prominently above the primary menu

Here is my .html code :

{% load i18n %}
<div class="customer-context-menu closed {% if customer.gender == 0 %}male{% else %}female{% endif %}">
    <b class="unselectable">
        {{ customer.icon }}
        {{ user.get_full_name }}
    </b>
    <ul>
        <li><a href="{% url "customers:perceptions" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Perceptions" %}</a></li>
        <li><a href="{% url "customers:profile" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Profile" %}</a></li>
        <li><a href="{% url "customers:alerts_index" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Alerts" %}</a></li>
        <li><a href="{% url "customers:messaging" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Messaging" %}</a></li>
        <li><a href="{% url "customers:requests" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Requests" %}</a></li>
        <li><a href="{% url "customers:documents" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Documents" %}</a></li>
        <li><a href="{% url "customers:logs" cust=customer.pk %}" class="unselectable" data-turbolinks="false">{% trans "Logs" %}</a></li>
        <li class="separator"></li>
        <li><a href="{% url "customers:loan" cust=customer.pk pk=loan.pk%}" class="unselectable" data-turbolinks="false">{% trans "Loan" %}</a></li>
        <li><a href="#"># Loan </a>
            <ul>
                <li><a>{% trans "Perceptions" %}</a></li>
                <li><a>{% trans "Perceptions" %}</a></li>
                <li><a>{% trans "Perceptions" %}</a></li>
            </ul>
        </li>
        <li class="separator"></li>
        {% if customer.phone_1 %}
        <li class="phone">{{ customer.phone_1 }}</li>
        {% endif %}
        <li><a href="mailto:{{ user.email }}" data-turbolinks="false"><i class="material-icons">email</i> {{ user.email }}</a></li>
        <li><a href="{% url "customers:print" cust=customer.pk %}" class="unselectable" data-turbolinks="false" target="_blank"><i class="material-icons">printer</i> {% trans "Print" %}</a></li>
    </ul>
</div>

I wish to create a multi-level dropdown menu using this code (e.g., ).

However, I am facing issues with the CSS styling. Currently, the submenu appears in front of the main menu rather than on the right side. Here is an image of the current layout: Picture. How can I resolve this problem?

Thank you in advance!

P.S. Please inform me if the question lacks clarity.


.customer-context-menu b {
  display: inline-block;
  border: 1px solid #ccc;
  padding: 5px 14px 2px 7px;
  font-size: 12px;
  border-radius: 13px;
  cursor: pointer;
  white-space: nowrap; }
  .customer-context-menu b .material-icons {
    float: left;
    margin: -3px 4px 0 -5px; }

/* More CSS styles follow... */

Answer №1

It would be ideal to provide a complete working code snippet with the issue isolated, but since that is not available, here is a simple example showcasing the desired functionality which can be easily incorporated.

.container {
  width: 200px;
  height: 40px;
  background: lightgray;
  position: relative;
}

.container:hover .submenu {
  display: block;
}

.submenu {
  width: 200px;
  height: 40px;
  background: gainsboro;
  position: relative;
  display: none;
}

.submenu:hover .sub-submenu {
  display: block;
}

.sub-submenu {
  width: 200px;
  height: 40px;
  background: gray;
  position: relative;
  top: -18px;
  left: 200px;
  display: none;
}
<div class="container">
  main menu
  <div class="submenu">
    first sub menu
    <div class="sub-submenu">
      right sub menu
    </div>
  </div>
</div>

Answer №2

To prevent your submenus from overlapping with their parent elements, make sure to add an offset equal to the width of your first level links since all your menu's "ul" elements are positioned absolutely:

.customer-context-menu ul ul { left: 300px; }

Answer №3

If you're facing a similar situation, you might find this snippet helpful from my previous experience.

// This code is clear and well-commented

Check out the code on jsFiddle

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

CSS - What's the best way to create a dynamic resizing input box in web design?

How can I create an input box that automatically wraps text and shrinks to fit its size? What CSS property should I use for this? I attempted to use width: auto to scale it, but it didn't work as I expected. ...

Remove three text elements to the right of the small icon with no line breaks

I am trying to align three text items to the right of a smaller left-floated icon without causing the text items to wrap. div { width:30%; } div i { margin-right:0.75em; padding:0.5em; float:left; color:#fff; border-radius:50%; ...

Multiple callbacks triggered by jQuery CSS transitions

I am experiencing an issue with my menu animation. I am curious as to why the slideDown transition is occurring twice. You can view the JSFiddle here. <ul class=top-menu"> <li>Item 1</li> <li>Item 2</li> <ul cl ...

Ensure that the element is positioned above other elements, yet below the clickable area

Currently, I am working on developing a notification system that will display a small box in the top right corner of the screen. However, I am facing an issue where the area underneath the notification is not clickable. Is there a way to make this part o ...

Look for a regular expression that matches numbers ranging from 1 to 31, either with or without a leading

I am in the process of setting up validation on an <input> element to prevent the user from inputting incorrect characters. Currently, I am utilizing ng-pattern for this purpose, which successfully restricts the user from entering invalid characters. ...

Adjust the size of the div based on a percentage of the header div

I'm looking to add a new div within the header of my WordPress site. I want this div to be a percentage of the parent div's size, specifically occupying only the right side of the header. Right now, the header contains my logo on the left side, a ...

Prevent users from adding or removing any letters

Exploring the ACE Editor integration with AngularJS (utilizing UI-Ace). I have a question. Is it possible to limit the user's actions to: Only allow entering a predefined character (for example, ;) Prevent deletion of any characters except for the p ...

Leveraging the Bootstrap 3 audio player, although displaying a standard HTML5 output

When trying to use the Bootstrap 3 player to display an audio player, I'm encountering an issue where the page only shows a default black HTML5 audio player output. Here is my current directory structure: miuse/ application/ bootstrap/ ...

Spring Boot application on Prime Faces is not displaying CSS after deployment to Heroku

I'm currently using a combination of Spring 3.1.3, Prime Faces 3.4.2, Hibernate 3.6.8, and Pretty Faces 2.0.4. When I deploy my application on a local server (Apache Tomcat 7), the CSS displays properly. However, when I deploy the same project to Her ...

Conceal the button and reveal the hidden paragraph by clicking the button

I'm trying to create a button with dual functionality - when clicked, the button should disappear and a hidden p-tag (with display: none;) should become visible. <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis. ...

Template not found: Error encountered in nodemailer-express-handlebars: ENOENT: The specified file or directory does not exist in the node

I've been attempting to utilize nodemailer and express-handlebars in my node.js application to send a template form. However, I keep encountering the "no such file" error. Unfortunately, I have no clue what I'm overlooking or missing. Here is m ...

Establish limits for dates by binding them to variables

After spending hours grappling with AngularJS directives, I finally managed to get my date picker functioning. However, one crucial element that would enhance its functionality is enabling the live change of the min- and maxDate values. Consider this sc ...

How to utilize the ternary operator efficiently to evaluate multiple conditions in React

Is there a way to change the style based on the route using react router? I want the description route to display in orange when the user is in the description route, white when in the teacher-add-course route, and green for all other routes. However, th ...

Exploring AngularJS concepts with a focus on understanding view problems (ng-if, ng-switch)

As a beginner diving into the world of AngularJS and JavaScript, I find myself facing a challenge that I hope to get some advice on today. The issue revolves around displaying an input block with or without the "readonly" attribute. To better explain my pr ...

Avoiding the use of a particular URL when using this.router.navigate() in AngularJs

In my angularJS registration form, I am using a bootstrap template for the design. The URL path to access the form page is http://localhost:4200/signup <form method="post" (submit)='register(username.value,email.value,password.value)'> ...

I'm currently facing an AttributeError issue, and I'm seeking solutions to resolve it

Currently, I am in the process of developing an eCommerce platform using Django. However, I have encountered an issue when attempting to manipulate the quantity of each product in the cart. The error message displayed is as follows: AttributeError at /orde ...

Google App Engine displaying a blank screen error

I've been playing around with this concept where there's a table of 'events' on a '/search' page. When the 'GO' button of an event is clicked, it should increase the 'RSVP' count for that event and redirect ...

Animating an image with CSS steps to create a captivating shaking

My attempt at creating a basic animation is not producing the desired smoothness. .animate { animation: motion 1.5s steps(27) forwards; } @keyframes motion { 100% { background-position: -5778px; } } <div class="animate ...

PHP Math Crunching

Hey everyone, I have created two separate pages: index.php test.php Here is index.php <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <form method="get" action="test.p ...

The Res.redirect function appears to be useless within my Angular-Express project

Here is my latest project in development. 1. Building a Node/Express Server 2. Implementing Angular Routes 3. Setting up Database functions 4. Creating Controllers In the first file, I have this specific function: function requireUser(req, res, next ...