Troubleshooting a problem with a CSS dropdown menu

For the past couple of hours, I've been trying to troubleshoot the issue with the fly-out menu on the homepage of this website.

When hovering over the capabilities link, the fly-out works correctly but the main background doesn't stretch to fit the width I specified while the hover state does. Here is the code:

HTML

<ul id="menu">
         <li><a href="index.php" class="current">Home </a></li>
         <li><a href="#">Capabilities </a>
           <ul class="innerul">
             <li><a href="quilt.html">Wire Harness & Cable Assemblies</a></li>
             <li><a href="quilting-services.html">Electro Mechanical Assemblies</a></li>
             <li><a  href="bags-&amp;-totes.html">On-Site Machine Shop</a></li>
             <li><a href="zombie-felties.html">Facilities & Equipment listing</a></li>
             <li><a href="coming-soon.html"> Quality Assurance</a></li>
             <li><a href="coming-soon.html"> Computer Control System</a></li>
           </ul>
         </li>
         <li><a href="process-control.php">Process Control</a></li>
         <li><a href="about-us.php">About Us</a></li>
         <li><a href="contact-us.php">Contact Us</a></li>
       </ul>

CSS

#menu
{
        width: 100%;
        margin: 0;
        padding: 0px 0 0 0;
        list-style: none;

}

#menu li
{
    float: left;
    position: relative;
    width: 192px;
    padding-top: 0;
    padding-right: 0;
    padding-bottom: 10px;
    padding-left: 0;
    margin: 0px;
    text-align: center;
}



#menu a
{
        float: left;
        height: 25px;
        text-align: center;
        width: 192px;
        color: #999;
        text-transform: uppercase;
        font: bold 12px/25px Arial, Helvetica;
        text-decoration: none;

}

#menu .innerul li li:hover > a
{
    color: #fafafa;
    width: 250px;
}

*html #menu li a:hover /* IE6 */
{
        color: #fafafa;
}

#menu li:hover > ul
{
    width: 250px;
        display: block;


}

/* Sub-menu */

#menu li .innerul
{
    list-style: none;
    width: 250px;
    margin: 0;
    padding: 0;
    display: none;
    position: absolute;
    top: 20px;
    left: 0;
    z-index: 99999;
    background: #192833;
    background: -moz-linear-gradient(#1f323f, #192833);
    background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #192833);
    background: -webkit-linear-gradient(#1f323f, #192833);
    background: -o-linear-gradient(#1f323f, #192833);
    background: -ms-linear-gradient(#1f323f, #192833);
    background: linear-gradient(#1f323f, #192833);
    -moz-border-radius: 5px;
    border-radius: 5px;
}



#menu li .innerul li
{
    float: none;
    width: 250px;
    margin: 0;
    padding: 0;
    display: block;
    -moz-box-shadow: 0 1px 0 #010101, 0 2px 0 #2b4253;
    -webkit-box-shadow: 0 1px 0 #010101, 0 2px 0 #2b4253;
    box-shadow: 0 1px 0 #010101, 0 2px 0 #2b4253;
}

#menu li .innerul li:last-child
{
    width: 250px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
}

#menu li .innerul li a
{
    width: 250px;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 0px;
    padding-right: 0px;
        height: auto;
    line-height: 1;
    display: block;
    white-space: nowrap;
    float: none;
        text-transform: none;
}

*html #menu ul a /* IE6 */
{
        height: 10px;
        width: 192px;
}

*:first-child+html #menu ul a /* IE7 */
{
        height: 10px;
        width: 192px;
}

#menu li .innerul li a:hover
{
    background: #0186ba;
     width: 250px;
        background: -moz-linear-gradient(#04acec,  #0186ba);
        background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba));
        background: -webkit-linear-gradient(#04acec,  #0186ba);
        background: -o-linear-gradient(#04acec,  #0186ba);
        background: -ms-linear-gradient(#04acec,  #0186ba);
        background: linear-gradient(#04acec,  #0186ba);
}

#menu li .innerul li:first-child a
{
    -moz-border-radius: 5px 5px 0 0;
    border-radius: 5px 5px 0 0;
    width: 250px;
}

#menu li .innerul li:first-child a:after
{
    content: '';
    position: absolute;
     width: 250px;
    left: 30px;
    top: -5px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 8px solid #1f323f;
}

#menu ul li:first-child a:hover:after
{
    border-bottom-color: #04acec;

}

#menu ul li:last-child a
{
     width: 192px;
    -moz-border-radius: 0 0 5px 5px;
    border-radius: 0 0 5px 5px;
}

/* Clear floated elements */
#menu:after
{
     width: 192px;
        visibility: hidden;
        display: block;
        font-size: 0;
        content: " ";
        clear: both;
        height: 0;
}

* html #menu             { zoom: 1; } /* IE6 */
*:first-child+html #menu { zoom: 1; } /* IE7 */
 #left {
    float: left;
    width: 700px;
    margin-right: 20px;
    height: auto;
    margin-bottom: 25px;
    margin-top: 0px;
}
#rack #header #navbar #menu li .innerul {
    margin: 0px;
    padding: 0px;
}

Answer №1

The CSS rule for your top menu is too generic compared to the inner one. Update #rack #header #navbar ul to #rack #header #navbar > ul in order to target only the top menu specifically.

In addition, adjust the width from 250px to 350px to ensure adequate space for text content.

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

Adjust the DIV dimensions to fit the background image perfectly

My question involves a DIV element with a specific style applied to it. .vplayer-container .logo { position: absolute; bottom: 50px; right: 10px; background: url(../img/logo.png) no-repeat; border: 1px solid #000000; max-width: 50px; max-height: 50 ...

In HTML, adjust column widths for multiple tables according to the widest column present in any of them

With Python, I am creating an HTML page that contains multiple tables with the same number of columns, all holding the same type of data. While the generated page is functional, I would like to improve readability by ensuring that all tables have the same ...

Learn how to customize the global style within a child component in Angular and restrict the changes to only affect that specific component

I have applied some custom css styling in my global style.css file (src/style.css) for my Angular project. However, I encountered a problem when trying to override this styling in a specific component without affecting the rest of the project. Currently, I ...

I've exhausted all options from stackoverflow with no success. Google Chrome's Autofill feature is wreaking havoc on my theme. Any suggestions on how to tackle this issue?

I designed a template with a stunning CSS layout. All I want is to have a transparent background with white font color, but Google Chrome seems to be causing issues with my theme. What steps should I take? I've exhausted all resources available onlin ...

Safari and mobile browsers do not support animation functionality

My animation works flawlessly in Chrome, but it's not functioning properly on Safari. Quite odd, right? Here is the code snippet: <header> <div class="ripple-1"></div> <div class="ripple-2"></div> ...

Guide on implementing CSS modules in a WordPress plugin built with React

Within one of my tsx files, I included this line: import styles from "../../styles/buyTicket.module.css"; This resulted in the following error message: ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/ ...

Struggling to properly position navigation bar items in a Bootstrap website

I'm struggling to align the bar items on a new site that I've built. I've tried placing two bars at the top to mimic the layout of this site: . I'd like it to look similar to this site: , where everything is nicely centered and mobile-f ...

The absence of the `breakInside` rule in GrooCSS

Currently, I am utilizing GrooCSS 1.0-GA for my CSS coding needs. Regrettably, it appears that GrooCSS does not provide support for breakInside as illustrated in the code snippet below: GrooCSS.process(new Config(prettyPrint: true)) { body { breakIns ...

What specific @media query should be used to target Windows Phone 8+ with high resolution?

As per the insights shared in Brett Jankord's article on Cross Browser Retina/High Resolution Media Queries The information suggests that Windows 8 phones do not adhere to device-pixel-ratio media queries. Are there alternative methods to target W ...

I have a flex box with an image and text line inside. How can I adjust the width of the box and text to automatically match the size of the image?

Consider the code snippet below: <style> .img_box { display: flex; } </style> <div class=img_box> <img src=img/> <div>Title text of varying length. It may exceed the image's width or be smaller.</div> & ...

Thumbnail vanishes upon being selected

To access my template site currently, please click here. Currently, the first thumbnail on my website is set up to display a gallery of images in FancyBox once clicked, similar to a question asked on StackOverflow that you can view here. Below is a snipp ...

Guide to optimizing the display of a responsive iframe across various devices such as mobile and desktop

I have implemented the following CSS in an iframe to make it responsive. It works well on desktop browsers, but on mobile browsers, the iframe only displays half of the screen. Can you please review the code below and provide guidance on how to fix this is ...

Is there a way to prevent an external script from making changes to an inline style?

There is a mysterious script running on a page that seems to be controlling the height of an inline style. The source of this script modifying the height property is unknown. <div class="vgca-iframe-wrapper wpfa-initialized" style="heigh ...

Avoid automatic background resizing to match the full width of the header text

I've been trying to use CSS to style my <h1> element in a specific way, but it seems the default browser behavior is getting in the way: https://i.sstatic.net/oRR5N.png Despite my efforts, the browser continues to display it like this: https: ...

Image overlaying the full width of body content background

I am trying to find a solution to my problem, but so far no luck. The Body selector has a max-width of 85%, and there are other selectors like header which I want to have a background image that spans 100% of the width behind the body selector attribute. ...

Struggling with implementing Mobile Navigation menu

I'm struggling to implement a mobile menu for my website. After adding the necessary code, when I view the page in a mobile viewport, all I see are two sets of periods ("..."). However, unlike in the code snippet provided, the list does appear on the ...

Using justify-content-between in a div container with only two items will not produce the desired effect

I'm having trouble aligning two elements on opposite ends of a div container using Bootstrap's justify-content-between class. The h4 element is not on the left and the button on the right as expected. I am using Bootstrap 5.2.3. Can anyone help m ...

Ways to prevent image toggling when the mouse moves out of it or when the hover effect stops

I'm looking to toggle between two images on mouseover/hover and stop the toggling when hovering stops. Here is the HTML code I have: <div class="fader"> <img src="image1" /> <img src="image2" /> </div> This is the JQuery ...

Guide to customizing WordPress header menu buttons with CSS, excluding a specific button

I need help with custom CSS for my WordPress site. I want to apply a hover effect to all menu buttons except for the "Contact" button, which already has its own styling. The CSS code adds a growing line beneath the hovered menu item and a static line unde ...

There seems to be an issue with the functionality of the JavaScript Quiz as it is

While working on my JS quiz, I encountered an issue where some answers were not displaying due to quotes and the need to escape HTML characters. Additionally, I am facing difficulty in accurately awarding points or deductions based on user responses. Curre ...