Ways to ensure CSS affects icon inside main element?

Struggling to match the background color of Material-UI icons with the rest of the list items on hover. The CSS is not applying to both the icon and text despite styling the overall class (className= "dd-content-item"). Any assistance would be greatly appreciated!

CSS:

/*Styling for each list element in the dropdown-content*/
.dd-content-item {
    color: #1D3557;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    list-style-type: none;
    cursor: pointer;
    justify-content: center;
    background-color: none;
}

/*Dark color on hover for list elements in dropdown menu*/
.delete-icon, .archive-icon{
    position: relative;
    top: 6px;
}

.favorite-icon, .tag-icon  {
    position: relative;
    top: 7px;
}

.dd-content-item:hover {
    background-color: #D3EDEE;
}

/*Dropdown-content displayed as block on hover*/
.dd-wrapper:hover .dd-content {
    display: block;
}

Code showing hierarchy in html Image of hover action

Answer №1

Are you using images or SVG icons? It's possible that your image doesn't have a transparent background.

If not, you can try something like this:

.dd-content-item:hover,
.dd-content-item:hover .delete-icon,
.dd-content-item:hover .archive-icon,
.dd-content-item:hover .favorite-icon,
.dd-content-item:hover .tag-icon {
    background-color: #D3EDEE;
}

It's difficult to determine without seeing the images themselves or knowing what type of objects they are.

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

Is there a way to transfer data from a custom hook to a component seamlessly?

I am facing an issue with a custom hook that passes parameter data along with fetched data to the Settings component. Inside Settings, I have a hook called setData11 in useEffect and I am trying to set the data passed from useTable but encountering an er ...

Having issues with uploading a webcam picture using ajax. Occasionally the image only seems to be saved partially. Any suggestions on what I might be

Working on my web application involves taking customer photos and uploading them with Ajax. I base64 encode the pictures, resulting in large data sizes (around 1.4MB). The process involves Ajax calling a php script to handle the data transfer and saving it ...

Exploring ReactJS: Understanding State and Local Variables

Reference: For more information on ReactJS state and lifecycle, visit this link In the assignment this.timerID = setInterval, is the variable timerID just a regular variable or should it be considered as part of the component's state? Why isn't ...

Flickity remains in plain sight on desktop devices

I am trying to hide the flickity slider on desktop and larger devices. I have followed the instructions in the documentation, but for some reason, it's not working as expected. Here is how the div looks: <div class="w-full flex pl-4 pb-16 overflo ...

Struggling to validate jest snapshot matching

I've been struggling with this issue for a few days now. I can't seem to get the '.toMatchSnapshot' test to pass, and it's clear that I'm missing something in my understanding of how it works. Should I be making changes to my ...

Unable to display Material UI icon in React app browser

Here is a list of the dependencies that have been installed: "dependencies": { "@emotion/react": "^11.8.1", "@emotion/styled": "^11.8.1", "@mui/icons-material": "^5.4.2", ...

Applying a specified style to a pseudo element using the ::after selector to display an

Can anyone help me with adding a pseudo element ::after containing an icon (from FontAwesome) to my Bootstrap Vue ProgressBar? I want this icon to be dynamic and move along the progress bar line when I click. Here is my current implementation, where the Pr ...

Creating multiple objects in a threejs instance with varying sizes and positions

Recently, I decided to try out the InstancedBufferGeometry method in order to improve performance when rendering thousands of objects. Specifically, I wanted to create instances of cube geometries with varying heights. AFRAME.registerComponent('insta ...

Preserve StepContent information within Material-ui Stepper during updates to the active step

I have a Stepper component with multiple steps, each containing several TextFields. The issue is that material-ui unmounts the step contents when you switch steps, causing all the data in the TextFields to be lost. My question is: Is there a way to prese ...

Warning in Google Script editor

Currently, I am working on creating some quick scripts to manipulate spreadsheets in my Google Drive. However, I am cautious about the script unintentionally running and making changes to data before I am ready or executing multiple times after completing ...

Show the date and time in a visually appealing way by using HTML and JavaScript in an HTA application with scrolling effects

I have the following JavaScript code to show the current date in the format Mon Jun 2 17:54:28 UTC+0530 2014 within an HTA (HTML application). Now, I would like to display it as a welcoming message along with the current system date and time: Mon Jun 2 17: ...

Align image within box using Bootstrap

My project screenshot is displayed below. The red line separates the current state from the desired outcome. I am struggling to make it fullscreen, meaning it should extend all the way to the corners. Despite trying various methods with Bootstrap 4, I have ...

Cufon failing to load following an ajax call

At first, cufon is used to replace the text on the main page. However, when another page file is loaded, cufon does not apply its replacement to the newly loaded content. Why is that? I tried adding cufon.refresh(); as the last function in the chain. I c ...

React - Pagination with page number not functioning correctly

Currently, I am trying to set up pagination for my website. When I visit localhost:3000/profile/, it displays the first 3 elements correctly. The pagination also functions properly when I input a number like 3 for ${page}, taking me to page 3 seamlessly. H ...

Ensure all coordinates are aligned within the boundaries of the map when using react in mapbox

Imagine a scenario where I have either one or two points on a map. Dealing with just one point is straightforward - I can zoom in and out as needed with that point as the center. However, when it comes to having two points on the screen, I'm unsure of ...

Retrieving data from a remote PHP server using JavaScript

I am currently working on two separate websites. Site A is coded using only HTML and JavaScript, while site B utilizes PHP. I am trying to figure out a way to access variables from site B within site A. For example: The code for site A looks something li ...

Different ways to manipulate the CSS display property with JavaScript

Having trouble changing the CSS display property to "none" using JavaScript. Check out my code: <div class="mydiv" onClick="clickDiv1()">hello</div> <div class="mydiv" onClick="clickDiv2()">hi</div> <div class="mydiv" onClick=" ...

Execute the controller function once all asynchronous calls to the Angular service have finished

I have integrated the Angular Bootstrap Calendar using a custom cell template and cell modifier. Within my controller, I need to retrieve configuration data from a service that is required by the cellModifier function before it is executed. (function() { ...

Removing the Tooltip for Sorting in React-Table: Here's How to Remove the 'Toggle sortBy' Tooltip from Column Headers

Is there a way to remove the 'Toggle sortBy' tooltip from the column header when using the Material-UI Table components in the most recent version (7.5.x) of React-Table? Two tooltips Upon hover, I have a tooltip displaying the column header na ...

When attempting to import and utilize a component from a personalized React Component Library, it leads to an Invariant Violation error stating: "

Currently, I am in the process of developing a React UI Kit/Component Library for internal use in our product line. Progress has been smooth so far, with everything functioning well and displaying correctly on Storybook. However, when testing the library ...