The hover effect is not extending the full width of the dropdown menu

I'm currently working on my first WordPress theme, trying to style the _'s theme. I've been focused on creating a dropdown menu, but I'm facing an issue - if one of the dropdown item headers is too wide, the hover color won't cover all the items within it.

Take a look at the content under "A Really Long Header Width".

Pardon the messy code, I'm still learning!

HTML

    <nav id="site-navigation" class="main-navigation" role="navigation">
            ... (omitted for brevity) ... 

http://jsfiddle.net/8v5Lpdxg/

Answer №1

The issue lies within the css code on line 44:

 .main-navigation ul ul a {
    width: 200px;
}

By setting a fixed width for anchor tags, it restricts their size. Removing this constraint will allow them to inherit the full width.

Delete that code and the menu items will expand to full width.

However, be aware that smaller menu items may no longer display correctly. To address this, you should add the following code to line 50:

.main-navigation ul ul li {
  width: 100%;
}

This will ensure that all sub menu list items always occupy 100% of the width (rather than just expanding based on content).

Take a look at the updated jsfiddle here.

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

A JavaScript function that is only triggered half of the time

After browsing through various forums like StackOverflow, I couldn't find a solution that perfectly fits my issue. I may be new to programming, but I've managed to create several projects already. Currently, I am working on integrating them into ...

My sub menu bar is not working properly, I need to fix it so that it can dropdown correctly

I'm struggling with my sub menu layout and need some assistance in fixing it. I've tried numerous times to adjust it using CSS, but without success. Here is the link to my menu. I'm still learning CSS and could really use some guidance: # ...

Responsive Bootstrap 4 Login Form with customized top height

This login form was created using Bootstrap 4, starting with a preset that I then customized to fit my needs. As someone new to Bootstrap and CSS, I struggled with making the form responsive. When resizing the window, the top portion gets cut off and is no ...

Differentiate various collections of shapes

My application has a specific workflow: 1) Next to the name of Patient X, there is a "Check In" button. Once clicked, this action is recorded on the server side. 2) Upon clicking the "Check In" button, a dropdown menu appears with various locations for t ...

Inconsistent and non-uniform sizing of table cells (<td> tags)

I'm currently working on creating an HTML table to use as the formatting for a banner and menu links on my website. However, no matter how much I adjust the size and margins, the menu link tags just won't seem to stay at an even size. <table ...

The sidebar should remain fixed on top when viewed on mobile devices, but not when viewed on desktop

Prior to beginning a new project, I'm interested in exploring the possibility of implementing a sliding sidebar for mobile and tablets. On desktop, however, I envision a fixed sidebar that is part of the main container layout as shown below: <div ...

In order to ensure JavaScript can be universally applied to all images, it needs to be made more generic

I have developed JavaScript functions to enable zoom in and zoom out functionality for an image through pinching gestures. Now, I aim to refactor the code below so that I can include it in a shared JavaScript file. var scale = 1; var newScale; ...

Ensure two CSS components occupy the entirety of their container, positioned next to each other, with margin spaces between

I am looking to make two elements take up a precise percentage of the parent's width, while also including margins between them. Here is my current setup: <div class='wrap'> <div class='element'>HELLO</div>< ...

AngularJS handles intricate JSON responses effortlessly

I have been learning angularjs on my own, mostly from w3schools and other websites. I have been trying to download and parse some JSON data. I was successful with a simple JSON url (http://ip.jsontest.com), but I am struggling with a more complex response. ...

Is there a way to adjust the font size for the label in mat-step?

Is there a way to update the design using only inline styles and CSS? Below is the code snippet I am working with: <div class="statusbar"> <mat-horizontal-stepper linear > <mat-step label="One" [complet ...

Creating an invoice or money receipt using HTML is a straightforward process that involves using specific code and

Currently, I'm in the process of developing an application for a land developer company. The administrator of this application will be responsible for creating invoices, money receipts, and bills. I am looking to design these documents to resemble th ...

Change the class when the scroll reaches the same letter block while moving up or down

Within this div, there is a horizontal list displaying all the alphabets. Below the list, there are blocks of names starting with each alphabet, with the header of each block matching the respective alphabet. I am looking to add a class to the div contain ...

Troubleshooting problems with the width of a Bootstrap navbar

I'm encountering a frustrating issue with my bootstrap menu. When I include the "navbar Form" in the menu, the width of the menu extends beyond the screen width in mobile mode (when resizing the browser window or viewing on a mobile device). Interesti ...

Having difficulty retrieving the value from a database column as it consistently displays both the column name and value

I am currently working on setting up a dynamic site title that will be controlled by my database. This way, I can easily update the database with a new title and have it reflect on my website. Below is an example of the controller setup: TestController: ...

What causes the parent and grandparent elements to shift when adjusting the margin of a header tag?

I'm facing an issue with the h1 tag where changing its margin-top property also affects the parent and grandparent elements. Can someone shed light on why this is happening and provide a solution? If you observe, setting the h1 margin to 0 auto creat ...

Dynamic manipulation of classes based on user attributes

One thing I've noticed is that certain WordPress themes, like 'Thematic', include user-specific classes in the body element to avoid using CSS browser hacks. For example: wordpress y2010 m02 d26 h05 home singular slug-home page pageid-94 pa ...

Fuel Calculation - Unable to pinpoint the error

My JavaScript Code for Calculating CO2 Emissions I'm working on a program that calculates how much CO2 a person produces per kilometer. This is part of my school project and I'm still learning, so please bear with me... I also just signed up on ...

Utilizing the CRUD object to input customer user data in Woocommerce

Currently, I am attempting to update the value of the first_name field for a user in woocommerce. My approach involves utilizing the 'CRUD Objects in 3.0' that are outlined in the latest documentation of woocommerce 3.0. So, I'm initializin ...

Unlock the power of Component level CSS in NextJS with this simple guide!

I don't have much experience with CSS, as I rarely write it these days due to the popularity of libraries like MUI. However, I recently found myself in a tricky situation where I needed to rewrite this example Emabla carousel in typescript and NextJS. ...

Highchart mortgage calculator for accurate financial planning

I am looking to create a dynamic high chart similar to the one on bankrate.com, showcasing principal, balance, and interest over various years. Despite my efforts, I have been struggling to organize the data by year as demonstrated in the example above: ...