Struggling to remove background image in WP CSS causing overlapping menus in submenu

I recently followed a tutorial on "Overlapping Tabs" for a WordPress project and found it to be quite helpful and functional. The tutorial can be viewed at

After implementing the tabs from the tutorial, I decided to add dropdown submenus to enhance the functionality. Although the submenus work well, I encountered an issue where the background tabs from the main parent menu are spilling over into the submenu despite having a no-repeat setting in the CSS.

I've attempted various solutions, such as looking for demos and tweaking the CSS, but I seem to be making things more complicated. Here is a snippet of the CSS code that showcases the issue:

.menu ul {
list-style: none;
position: relative;
float: right;
}

.menu ul li {
float: left;
background: url(../wp-content/uploads/2012/08/inactive_right.png) no-repeat right;
padding: 11px 54px 12px 0;
}

.menu ul li:hover > ul {
display: block;
}

.menu ul li a:hover {
color: red;
}

.menu ul ul {
display: none;
position: absolute;
z-index:999; 
background-color: white;
white-space: nowrap;
}

.menu ul li:last-child ul {
right:0;
}

.menu ul ul li {
clear: both;
padding: 5px;
}

.menu ul ul li a:hover {
color: blue;
}

An image demonstrating the problem can be seen here: menu problem http://glassdoctordenvermetro.com/wp-content/themes/GDDenverTheme/images/menu_problem.jpg

Answer №1

Your CSS is targeting all list items within the .menu class, including those in submenus. To restrict the styling to only first-level items, use the direct-child selector.

.menu > ul > li {
    ...
}

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

View box 2 from the opposite side of box 1

I am looking for a way to make box2 appear behind box1. One solution is to use position: relative; in the .box1 class. However, this causes another issue in my project. Is there a way to display .box2 behind .box1 without using position: relative; in .b ...

Adjusting the space between div elements when resizing the window

I am seeking guidance on how to ensure that the text boxes (div) on my page adjust themselves properly when the size of the page is shrunk. Currently, the text boxes tend to overlap when the screen size is smaller, which is not desirable. I need the boxes ...

The alignment of the text next to the icons is not correct

Is it necessary to use flexbox, or is there an easier way to achieve the same result? It has been a while since I last practiced and I can't seem to remember much. .sadaka-contacts p { color: #115c9b ...

Arranging items in a vertical column using Bootstrap styling

I am facing a particular issue: The initial design is displayed in Picture 1: I am using Bootstrap 5 as my CSS framework. I attempted to utilize the pre-built columns feature, but so far, I have not been able to find a solution and am currently strugglin ...

What is the best way to address the excess white space between an image and progress bar on larger screens while utilizing the Bootstrap Grid system?

https://i.sstatic.net/NXMNV.pngLet's begin by visualizing the concept through these images: In Picture (1), the progress bars are positioned below the image on medium to large screens, with the text aligned to its right. https://i.sstatic.net/Cw1aM.pn ...

React text hover image functionality

Just diving into the world of React and attempting to create a cool image popup effect when you hover over text in my project. I could really use some guidance on how to make it function within React, as the logic seems a bit different from plain HTML. Any ...

Comparing Animation Width with Background Image Size

I'm currently facing a challenge with making my animation resize automatically based on screen size, just like my background image does. The width of the animation seems to be inconsistent or doesn't stretch across the entire screen as I intended ...

Pictures are automatically adjusted to a resolution of 0 x 0 within the Heroku application

I have encountered an issue with my simple webpage hosted on Heroku. Despite appearing perfectly fine on localhost, 4 images are automatically resized to 0x0 when viewed on Heroku. I am struggling to identify the cause of this problem. Here is how it appe ...

Adjusting column styles on mobile or desktop devices

My row has two columns <div class="row"> <div class="col-9"> hello </div> <div class="col-3"> world </div> </div> But I want to change the column classes for small screens, so they would be ...

Is it possible for Penthouse to retrieve critical CSS while using javascript?

I am currently utilizing the laravel-mix-criticalcss npm package to extract the critical CSS of my website. This package leverages Penthouse under the hood, and you can configure Penthouse settings in your webpack.mix.js within the critical options. The ...

Use ngFor to align items to the left in your design

I am working on a div element where I need to dynamically add inputs that should form a number with a specific format. To ensure the inputs start from the left, I have applied the justify-content-end class. HTML: <div class='row justify-content-end ...

Guide to utilizing selenium webdriver for choosing an item in a Bootstrap select dropdown list

I'm trying to choose a country from the dropdown menu on . However, when using the code below, it seems to work intermittently and sometimes throws an error stating "Element not found(xpath("//*[@id='dvQuoteFrom']/div/button")) driver.find ...

Styles for reading on Safari using an iPhone's reader mode

Currently in the process of optimizing my website for iPhones and exploring the Safari reader function. I believe it's a useful feature for websites with lengthy text, similar to mine, but I want to customize it slightly. Is there a way to adjust th ...

What is the best way to align a logo in a log-in screen?

I am having an issue with centering the logo on my login form. The "signin" text is centered perfectly, but the logo always stays at the top left corner. I don't understand why the logo is not centered. If anyone has a solution to propose, I would gre ...

Customizing the sizes of HTML components (h1, h2, h3, etc.) with Tailwindcss for both desktop and mobile platforms

Currently, I am working on a project using Tailwind CSS and Next.js. I want to customize the font size of h1 element from 40px to 46px for desktop screens (1440px) and then adjust it to 30px for mobile web (375px). I attempted to add a new property in the ...

Learn how to separate two SCSS files and compile them into individual CSS files

Currently, I have two SCSS files that need to be compiled into separate CSS files. For one of the SCSS files, my script looks like this: "watch:sass": "node-sass assets/stylesheets/custom.scss assets/stylesheets/custom.css -w", "compile:sass": "node-sass ...

Connect two cells in a table by incorporating a vertical line in between the rows. Merge header cells

I have incorporated some simple HTML tables on my website and I am encountering two issues that I need assistance with. 1) After adding these tables to my subpage, I noticed that the tables look almost identical but have their horizontal line between tab ...

Is there a way to have a fixed width div positioned in the center of the screen, with two additional divs on either side

I have come across this stunning image: https://i.stack.imgur.com/tUYMc.png It serves as a header for a website - click on it to see the full size. I am trying to replicate this using HTML, CSS, and images, but I'm struggling. It needs to be 100% w ...

Obtaining the value with JQuery's .change() function

Currently, I am in the process of setting up dynamic drop-down selectors using JQuery. Despite being new to frontend development, I have encountered a challenge with retrieving the value of a dropdown once it has been changed using JQuery. The user flow I ...

Ways to create a responsive header image on a website

I recently incorporated a header image on my website using the following code: #header_area { background: url('my_header_image.com'); background-repeat: no-repeat; background-position: top center; } Although my website is responsive ...