The dropdown menu is unable to open directly below the main menu item

How can I make the submenu open to the left when hovering over a menu point, instead of directly under it? I have tried adjusting the position attributes but haven't found the right solution yet. The closest I got was by changing the display property from block to inline-block. Is there a way to achieve this without using JavaScript?

nav {
  background-color: cadetblue;
  position: relative;
  height: 60px;
}

ul.fixed {
  background-color: cadetblue;
  font-size: 22px;
  text-align: center;
  position: fixed;
}

ul.fixed li {
  display: inline;
  list-style: none;
  font-family: Bahnschrift;
}

ul.fixed li a {
  text-decoration: none;
  color: aliceblue;
  text-align: center;
  padding: 14px 20px;
}

ul.fixed li a:hover {
  background-color: gray;
  color: cornflowerblue;
  opacity: .8;
}

ul.Untermenue {
  display: none;
  position: absolute;
  background-color: gray;
  margin-left: 0;
  padding: 0;
  opacity: .8;
}

li.Untermenue {
  display: inline;
  position: relative;
}

ul.Untermenue li a {
  color: #D6D6D6;
  display: block;
}

.Dropdown:hover .Untermenue {
  display: block;
}

.Untermenue a:hover {
  background-color: cornflowerblue;
}
<nav class="Navigation">
  <ul class="fixed">
    <li><a href="Menü.html">Home</a></li>
    <li class="Dropdown"><a>Wir</a>
      <ul class="Untermenue">
        <li><a href="Menü.html">Home</a></li>
        <li><a href="Menü.html">Home</a></li>
        <li><a href="Menü.html">Home</a></li>
      </ul>
    </li>
    <li><a href="Menü.html">Haus</a></li>
    <li><a href="Menü.html">Contact</a></li>
  </ul>
</nav>

Answer №1

Make sure to update your CSS using the code snippet below

CSS

ul.Untermenue {
    display: none;
    position: absolute;
    background-color: gray;
    margin-left: 0;
    padding: 0;
    opacity: .8;
    left: 0;     /* Newly included class */
}

ul.fixed li {
    display: inline;
    list-style: none;
    font-family: Bahnschrift;
    position:relative; /* Newly added class */
}

OUTPUT

https://i.sstatic.net/FUdx6.png

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

Filestack - NoCrop: Utilize whitespace to maintain the square aspect ratio when uploading images without cropping

Is there a way to use Filestack to upload an image and automatically add whitespace to the sides of the image in order to keep it square without cropping? click here for image ...

Capturing user input with Angular Material forms in HTML

In the process of working on a project in Angular, I am utilizing the Angular Material component library. As part of this project, I am creating a form with multiple fields. Everything is functioning properly, however, the layout appears slightly off: ht ...

Is there a way to properly size and align an inline image within a dynamically resizing DIV element?

I am working on a fluid layout where I have a div that always matches the height and width of the browser window, regardless of resizing. Essentially, this div is set to be 100% height and width of the browser window. Inside this div, I have an image that ...

dual slider controls on a single webpage

I am attempting to place two different sliders on the same page. When I implement the following code for one slider, it functions correctly: <h3>Strength of Belief</h3> <div class="slidecontainer"> <div class="slider_left"> < ...

The jQuery pop-up fails to activate on the initial click

I have multiple "Buy Now" buttons for different products. If the button is labeled as "sold-out," it should not do anything, but if it's available, it should trigger a jQuery Magnific Popup. Currently, the popup only opens after the second click becau ...

Activate the textbox without utilizing `.focus()` method

I am encountering an issue with a small iframe on my page. The content within the iframe is larger than the window itself, requiring users to scroll around to view it in its entirety. Within this iframe, there is a button that, when clicked, triggers an an ...

How can I stop and hover over time in AngularJs Interval?

Within my UI, I have a time element that is continuously updated using AngularJS Interval. Even the milliseconds are constantly running. Is it possible to implement a feature where the time pauses when hovering over it? Any assistance would be greatly appr ...

Trigger the activation of an input field upon clicking an image labeled "edit"

I am currently developing a website where administrators have access to a dashboard page that displays a list of users. I am looking to implement a feature that allows admins to change the roles of other users directly from the same table row. Below is th ...

Tips for Aligning an Image Just Above a Card in Mobile and Tablet Screens with Tailwind CSS

https://i.stack.imgur.com/tPXEQ.jpg https://i.stack.imgur.com/3XkJo.jpg Just a heads up, this code snippet performs well on desktop but may have some issues on mobile and tablet devices. If anyone in the StackOverflow Community can offer some assistance, ...

What is the best way to determine if a date is empty using Vuetify?

Could someone help me with checking if a date was entered by the user? I want to display an error message if a date is not provided. I attempted to use a rule for this purpose, but unfortunately it's not showing any error message. Below is the code I ...

Unique rephrased text: "Varied wrapping styles in both

Feeling frustrated with a seemingly commonplace issue. Despite the thousands of times it has been asked before, I can't seem to find an answer on Google. I wanted to neatly display my text within one of my cards, but so far I've only achieved th ...

Enhance the functionality of Woocommerce email notifications by incorporating a customized VAT field

I have exhausted all options and tried various email hooks without success. I inherited an outdated PHP code that was developed by someone else, which I updated for new woocommerce hooks (since the code is 4 years old). Everything is functioning smoothly e ...

Leveraging the capabilities of the Freshdesk API

Has anyone had any experience utilizing the FRESHDESK API specifically for creating tickets? The documentation states the following: Request URL: domain_URL/helpdesk/tickets.xml Request method: POST <helpdesk_ticket> <description>Disk fai ...

Display user's name in navigation bar using asp.net mvc

When working on an ASP.NET MVC project, I wanted to include a short message for the user, such as 'Hello, username!' In the navigation bar, specifically when the user is signed in, I encountered some display issues with the standard bootstrap la ...

Attempting to implement an EventListener to alter the navbar upon scrolling, unsuccessful at the moment

Exploring ways to update the navigation bar upon scrolling to shrink its size and modify the color scheme (specifically, transitioning from a transparent background to white and altering font colors). Below is the HTML snippet: /* Defining the overa ...

Duplicate the LI element in a way that it is inserted after the original LI instead of at the end

I am looking for a way to clone an item immediately after clicking on it instead of cloning it at the end of the list. Currently, it always clones to the END and adds it after the last LI in the list. Here is a link to the jsFiddle I created jsfiddle test ...

Outlook issue with table sizing

I'm trying to display a table with 14 columns in Outlook mail, but the column headings are too long and don't fit on one line. I've tried setting widths for each column, but the entire table doesn't widen as expected. For example, if I ...

The img-fluid class is not properly adjusting the height of the image

I'm currently working with Bootstrap 4 and facing a challenge with creating a grid of 4 images - 2 on top and 2 at the bottom. I've applied the img-fluid class, but the image resizing is based solely on width, leading to the height being too larg ...

Python: Utilizing the requests library to handle webpage redirections

Update: While this may not directly answer the question I had initially, I was able to find the necessary information in the API which provided a solution for my software. My current task involves logging into a webpage, navigating to another page, and ex ...

Customizing Navigation Color on Laravel Websites for Staging and Live Servers

I am seeking a solution to change the color of the Laravel navigation bar depending on whether it is the live or staging server. Our current setup involves testing code on a staging server before pushing it to the live server in production via Bitbucket. ...