Adjust the color of a linked tab with a dropdown list on WordPress navigation menu using CSS

I'm currently working on a WordPress website utilizing the Twenty-Twelve theme. One of the main menu tabs is labeled 'Sales Items'.

When hovering over this tab, it displays various categories of sales items in a dropdown list. However, I am struggling to change the color of the 'Sales Items' tab itself without affecting the colors of the links in the dropdown list.

Every attempt to target only the Sales Items menu tab in CSS ends up changing the color of all the dropdown list category items as well.

If anyone knows the correct CSS code to achieve this, your help would be greatly appreciated!

You can find my website at

Thanks in advance for any assistance!

Answer №1

One way to style sales items is by adding a specific class to the tag in the HTML code. This will require editing the HTML, resulting in code like this:

<a class="targetsale" href="http://www.thecolourmarket.com/product-category/clothing/sale-items/">Sale Items</a>

You can then apply CSS styles to this specific class.

If you are unable to modify the HTML directly, another approach is to target the sale item itself and then its sub items. For example:

li#menu-item-579 a{color:red;}   //styles sale items
li#menu-item-580 a{color:black;}  //styles coats & jackets

Answer №2

To customize the "sales items" tab specifically, you can utilize the ID #menu-item-579 or the class .menu-item-579 in your CSS file. For this example, I will be using the ID.

If you wish to modify the text color, you can include the following:

#menu-item-579 a {
    color: #5bad13;
}

To change the background color, you can use:

#menu-item-579 {
    background-color: #5bad13;
}

When adjusting the background color, you may notice that there is no padding on the left and right sides. Therefore, you might want to add some padding as well.

#menu-item-579 {
    background-color: #5bad13;
    padding: 0 13px;
}

However, after adding the padding, you may realize that the submenu is not correctly positioned. In this case, you will need the ID or class for that particular submenu. It may be challenging as the submenu does not have a unique class, but you can use the main menu's unique class/id instead.

#menu-item-579 .sub-menu {
    margin-left: -13px;
}

I hope this aligns with what you had envisioned. Good luck!

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

CSS Dropping Down Menu Design

Hello everyone! I am taking my first step into web development and currently in the process of revamping my DJ website. Check out my updated site here: I am working on creating a dropdown div within the top-left menu that will display information about t ...

"Enhance your browsing experience with Chrome by automatically changing the background when

I am currently using Chrome with a CSS3 background. <h4 class="title-name clearfix"><a href="****************">Fairy Tail - LUCY</a> </h4> My issue is that when I hover my mouse over the title, the ba ...

What is preventing Kohana from reading my CSS?

Recently, I launched my website kipclip.com on the Kohana platform and added a new rental page. However, the CSS and JS files are not being applied to this page. I've looked into how these files are included in Kohana but haven't had any luck so ...

Keep the table header in place while scrolling

I am currently working with Bootstrap V4 alpha 6 and Angular 5 to develop a table that includes a fixed header while scrolling. Unfortunately, I have been facing challenges in getting this functionality to work effectively. Note: The navbar is set to fixe ...

Is there a method, like using jQuery, to insert `<br>` tags into each line of a dropdown select list?

I need help with implementing a select tool in a limited horizontal space with each line containing a lot of information. I attempted to embed a tag into the line but it didn't work. Are there any solutions available that could provide a simple fix ...

Can someone explain why my button icons are not aligning to the center properly?

I have a small issue with the icons I pulled from react-icons - they appear slightly raised within the buttons. How can I position them in the middle? That's my only query, but I can't post it alone due to mostly having code in my post. What an ...

Is it possible to smoothly switch between two states using just a single animation class?

I am trying to trigger an animation with a single class, and then have that animation play in reverse when the class is removed. To better explain, I have created a CodePen example of my current progress. In the CodePen, you can see that when the class . ...

What is the process for adjusting the color of a mat-divider?

Has anyone been successful in changing the color of mat-divider? I attempted the following but had no luck: component.html <mat-divider class="material-devider"></mat-divider> component.scss .material-devider { color: red } ...

A different approach to achieving a newspaper-like text justification in HTML

When I have a paragraph with text-align:justify, the spacing between words can become uneven due to certain words. I used to rely on the property text-justify:newspaper; which helped break up the words for more evenly spaced text, but unfortunately, it is ...

Using Django, CSS, and Javascript, create a dynamic HTML form that shows or hides a text field based on the selection

How can I hide a text field in my Django form until a user selects a checkbox? I am a beginner in Django and web applications, so I don't know what to search for or where to start. Any guidance would be appreciated. Here is the solution I came up wi ...

Tips for integrating scroll-snap and jQuery's .scroll() function together

I'm facing challenges in integrating both of these elements into the same project. When I activate overflow: scroll, my jQuery function does not work as expected. However, if I deactivate it, then the jQuery works but the scroll-snap feature does not ...

Verify whether the content within the Div has been modified

I am currently making changes to content within a <div> element. I would like to determine if the data in the <div> has been modified and, if so, save it in a session to persist on refresh. How can I verify if the data has been edited and then ...

Effortlessly switch between multiple divs with jQuery

I am working on a functionality where multiple divs should be displayed or hidden based on the button clicked. Initially, all buttons and divs are visible. Upon clicking a button, only the corresponding div should be visible. Subsequent clicks on other but ...

When there are more than two divs on the page, they tend to overflow beyond the boundaries of

I am managing a platform where users have the ability to share text-based posts, and other users can engage with those posts through comments. An issue I have encountered is that once more than two comments are posted on a parent post, they start to overfl ...

Fading CSS Hover Popup Display and Hide

I am looking to create a CSS-only popup for an image that will appear when a user hovers over the image with their mouse. After researching on various platforms, such as this thread, I have developed the following solution: a.tooltip span { width: 250 ...

Steps to customize a CSS file within node_modules

Is there a way to make changes to a CSS file in the "node_modules" dependency without them being overwritten when I run npm install? I want to keep the modifications I've made to the node module files. ...

Tailoring Width with css

Apologies for posing this question, but I am curious about customizing the width of a Parent Div that is currently set to 100px for both height and width, creating a square shape. Is it possible to adjust the width separately, such as top-width and bottom- ...

Reiterating the text and determining the length of the string

Currently, the script is capable of calculating the width of the script based on user input and can also determine the width of a string. However, I am facing an issue when attempting to repeat a string entered by the user. For example, if the user input ...

The conditional CSS appears to be malfunctioning

Hi, I am attempting to use conditional CSS in my stylesheet to set a different width for IE6. I have tried the following code but it is not working: div.box { width: 400px; [if IE 6] width: 600px; padding: 0 100px; } How can I su ...

Remove information from WooCommerce rest API (both all orders and individual order) endpoint

My current project involves creating an app for vendors to manage their orders and facilitate the shipment of products to the front store counter. For the vendors, I want only the following information to be visible: Order ID Order Date Order Status The ...