Dropdown menu malfunction

I'm having an issue with the submenu - when I hover over the 'About' section, the dropdown menu width is larger than it should be. Can someone please help me figure out what I did wrong and how to fix it? Any suggestions related to my CSS code would be greatly appreciated.

Check out my JSFIDDLE

Below is the snippet of my CSS code:

* {
  margin: 0;
  padding: 0;
}

.main-nav ul {
  margin-left: 40px;
  margin-top: 40px;
  list-style-type: none;
}

/* Rest of the CSS code goes here */

Answer №1

I stumbled upon the perfect fix that you've been searching for. Take a look at the link provided below...

https://jsfiddle.net/Dhruvil21_04/x40psw2c/1/

OR

Here's how you can update your CSS selectors with just 4 simple changes...

/*--------Replace-------*/

.sub-nav {
    padding: 0px;
    float:none;
    position: absolute;
    top: 100%;
    left: 0;
    overflow: visible;
    width: 100%;
}
.main-nav li:hover {
    cursor:pointer;
    background-color: #0361D6;
    color: #C4C4C4;
    position: relative;
}

/*--------Add-------*/

.main-nav ul ul > li {
    padding: 20px 10px;
    text-align: center;
}
.main-nav ul ul {
    margin: 0;
    padding: 0;
    left: 0;
}

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

I was able to resolve the fixed position issue of a button on Safari for iPhone 3G

Here is the setup I have on jsfiddle: http://jsfiddle.net/zZDqH/ Currently, there is a button fixed at bottom:0px. You can scroll up and down the page, and the button will stay at the bottom of the page. However, when testing in Safari on an iPhone 3G ( ...

Pressing exclamation mark plus the enter key does not seem to function properly in VS Code's latest update (June 2022, version 1.69)

Since the recent VS Code update, I've noticed that I can no longer use ! + enter to automatically generate my base code. The only thing that changed was the update, and I also set up a new Git repository where I ignored the VS Code folder. Now, I&apos ...

When attempting to parse a JSON feed with jQuery and innerHTML, the data fails to display

Having trouble parsing a JSON feed using jQuery and innerHTML, but for some reason it's not working as expected. No errors are being displayed in the console and the feed itself is functioning properly. Not quite sure why this issue is occurring. < ...

The Bootstrap glyphicon content breaks when using ASP.NET MVC minification

When working with asp.net, I noticed that minification tends to disrupt the display of bootstrap UTF symbols. For example, here is what it looks like in the original file: .glyphicon-edit:before { content: "\e065"; } And here is how it appears in ...

Struggling to dynamically append additional textboxes to a <div> element using JavaScript

After spending over 12 hours on this problem, I am completely stuck and frustrated. I have tried countless variations and sought out other solutions to no avail. It should be a simple task. My project involves using JQueryMobile 1.2 along with its dependen ...

Working with AngularJS: Managing the values of two separate submit buttons

I'm trying to create a form with two submit buttons that will determine whether the form is saved as a draft or as a correct submission. One solution I am considering is adding a value/property to the submit buttons, perhaps using the ng-model attrib ...

Changing the margin-top of a nested div within a parent container div will cause both elements to be displaced downwards from the main body

I am facing an issue that I believe is a result of something silly I may have done, but I can't seem to pinpoint it. Here's a demonstration page illustrating my problem. Below is the source code for the page: <html> <head> <ti ...

Errors in the console appear when jQuery loads HTML containing images

Whenever I attempt to load a simple piece of HTML (though some images are currently inaccessible), jQuery seems to be attempting to load them, resulting in errors in the console. Here is an example of the code: var html = $('<div>' + &apo ...

What steps should I take to generate the category pages?

I'm currently working on a recipe blog that will feature various categories like breakfast, dessert, lunch, etc. I'm struggling with how to properly link these category pages. For instance, when users click "see all" for the breakfast category, i ...

"Utilize jQuery to superimpose an image on top of

I'm attempting to create a feature where clicking on an image will reveal text underneath, similar to how retailmenot.com displays coupon codes. In addition, when the image is clicked, users should be directed to an external URL. Here is an example o ...

Should we eliminate the overflow from multiple divs in the container, rather than just hiding it, or should we limit the overflow to

Looking for a solution to create a background that adjusts the number of square divs based on the size of the container, which changes when resizing the window. I tried referencing examples from this post here to add the divs. However, the issue arises wh ...

Achieving a perfectly centered alignment of two divs in Bootstrap 5 can be accomplished by placing one div with an input field next to another div

I am trying to center an input and a button on the same line within a div in the middle of the page. Currently, as shown in the image, they are aligned to the left of the page and I want them to be centralized. https://i.sstatic.net/o3RLs.png <div cla ...

How can I modify the HTML code for rooms in the HTML 5 client of the bigbluebutton application?

Is it possible to customize the HTML code of rooms within the BigBlueButton source code? Additionally, how can I modify the CSS styles of elements in room sessions? For instance, I am interested in hiding the logo of BigBlueButton by setting 'display: ...

Creating an HTML table by populating it with data from a JavaScript array

Imagine you have a JavaScript array structured like this: [ "Heading 1", "Heading 2", "Data 1", "Data 2", "Data 3", "Data 4", ] Your task is to generate an HTML table from this array that looks like the one in this link: https://i.stack.imgur.com/7laUR. ...

Retrieve information from a webpage with webharvest

I'm attempting to scrape all the HTML pages from the website "http://www.tecomdirectory.com/" using webharvest. However, the script isn't successfully fetching all the HTML pages and is only able to scrape a few of them. Below is the script that ...

Moving a button to the right side in HTML/CSS without creating any gaps

Currently, I'm working on developing a simple idle browser game. I'm facing a challenge in positioning a button on the right-middle of the box. I attempted using position: relative along with adjusting the bottom and left parameters, but I still ...

The Combobox event does not trigger properly on a change

My issue arises when trying to display the JDatePicker of jQuery UI in a different format upon an onchange event in a Combobox. The code I have does not work as expected when the second onchange event is triggered. Javascript Code $(document).ready(funct ...

Expanding the size of a text area input within a form using CSS and

How can I adjust the size of the text area in the Comment section to match the full width of the section, starting from the beginning instead of the middle? You can find the code here. HTML <body bgcolor="#00BCD4"> <div> <h1>Co ...

Want to know more about the font-face onload method?

I'm currently working on a loading screen which not only performs an animation, but also generates multiple img objects in JavaScript. These images are linked to an onload method that counts their progress. The loading process is completed once the co ...

What is the correct way to declare variables in a CSS custom fragment shader?

Whenever I attempt to define a custom variable in my CSS fragment shader, the shader inexplicably ceases to function. Despite being confident in the syntax, I can't figure out why this issue persists. Below is the excerpt of my HTML code and CSS: #h ...