Is there a way to modify the background color of ::before when hovering over it?

I have a ul-li list and when i hover last li ::before element looks white and not so good. I want to change it when i hover the last li element. How can I achieve this? Here are my codes:

<div className="dropup-content">
  <ul>
     <li className="content-item">
               <a
                 className="content-link"
                 href="#" 
                 target="_blank"
               >
                 <i
                   className={`  content-icon `}
                 ></i>
                 <div className="content-info">
                   <span
                     className={`content-info-name }`}
                   >
                    Name
                   </span>
                   <span className="content-info-subtitle"><Subtitle</span>
                 </div>
               </a>
             </li>
             <li className="content-item">
              .
              .
              .
    </ul>
</div>
       

CSS:

.dropup {
  position: relative;
  display: inline-block;
  transition: all 0.2s ease;
}
.dropup-content {
  display: none;
  position: absolute;
  background-color: #f1f1f1;
  bottom: 79px;
  right: 3px;
  width: 250px;
  z-index: 1;
  border-radius: 5px;
}
.dropup-content::before {
  position: absolute;
  bottom: -8px;
  right: 25px;
  left: auto;
  display: inline-block !important;
  border-right: 8px solid transparent;
  border-top: 8px solid #f1f1f1;
  border-left: 8px solid transparent;
  content: "";
}

What I've tried:

.content-item:hover:last-child .dropup-content::before {
  background:red;
}

https://i.stack.imgur.com/G4CLw.png

I need to change that color to gray on hover. What can I do?

Answer №1

.drop div {
  position: relative;
  padding: 10px;
}

.drop div:nth-of-type(odd) {
  background: #eee;
}

.drop div:nth-last-of-type(1)::after {
  content: 'after';
  position: absolute;
  color: teal;
  bottom: 0;
  left: 100px;
}
.drop div:nth-last-of-type(1):hover::after {
  color: red;
  background: #fff;
}
<div class="drop">
  <div>item A</div>
  <div>item B</div>
  <div>item C</div>
</div>

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

What is the process for transferring data from Express to Reactjs using socketio?

I'm currently working on a basic authentication app for Instagram. Once the user is authenticated and I have their profile data, I want to send the username from the server side to the client side in ReactJS. However, my attempts using socket IO are n ...

EJS is having trouble locating an image within the static public directory

I'm currently facing an issue with rendering a HTML template as a PDF using EJS. Despite my efforts, the images are not displaying properly. Here is how my project is structured: - public - images image.jpg - routes documentsRoute.js ...

Discovering the center of an element and implementing a left float

I'm looking for a way to dynamically position the element #ucp_arrow in the middle of a div using float: left. Here is an illustration: https://i.stack.imgur.com/nzvgb.png Currently, I have hard-coded it like this: JAVASCRIPT: $("#a_account").cli ...

How to use fp-ts to add an element at a specified index using insertAt function

Is there a way to easily add elements at a specific index using the insertAt utility function from fp-ts? The insertAt function returns either Option<T[]> or NonEmptyArray, resulting in an object structure like this: const x = insertAt(1, 100)([0, 10 ...

What is the best way to remove table row data fetched from an API within a table?

Can someone assist me with deleting the table tr from the user table, where data is retrieved from an API? I have attempted the code below: $("principleTable").find("tr").hide(); $("#delAgentModal").modal("hide"); ...

Querying a body in GraphQL within Gatsby: A Simple Guide

Recently, I embarked on creating a blog by following a 2019 tutorial that utilized the contentful-plugin. However, upon researching the updated documentation from Gatsby, I encountered some discrepancies which hindered my progress. My primary issue lies in ...

What makes the location props of React Router exclusive to Context?

I am currently developing a react-app using react-router-dom. I encountered an issue where the information passed in the Link component is only available in Context and not in props. Can anyone explain why this is happening? How can I access this informati ...

Tips for making your inner content as wide as possible

I'm currently working on developing collapsible tables, where an outer and inner table are displayed for every row that is clicked. This is the code I have implemented: HTML: <table class="table outerTbl mb-0"> <thead> <t ...

Issue with rgba background color not working in Bootstrap 3 navbar

Attempting to change the background color of bootstrap's navigation bar to a lower opacity rgba one, but facing difficulties. There are no changes being reflected at all. Below is the custom navbar CSS: .navbar-custom { background-color: rgba(255 ...

Populate Jquery datatables programmatically

After implementing the Jquery Datatables plugin, I initially had hardcoded content in the table. However, I made some modifications to dynamically populate the table with fetched data. While this change worked fine, I encountered issues with the search f ...

getting v-model value updated when clicking button

How can I update the value of v-model DataJournals.Description in a looping data when a button is clicked? This is what I have attempted: template <tr v-for="(DataJournals, index) in DataJournal" :key="DataJournals.value"> <td> & ...

Getting the badge value of a button in Angular JS is a simple process that involves accessing

How can I retrieve the badge value of a Button? This badge represents data-text-as-pseudo-element and I am new to Angular. Can someone guide me on how to achieve this? <style type="text/css">[data-text-as-pseudo-element]::before { content: ...

Navigating Up a Directory with JQuery

Is there a way to navigate up one directory level in my jQuery code? The code below is referencing a folder named "uploads" on the C drive, but I can't find any mention of "uploads" in my HTML. How does it know to look there? And how can I go back to ...

Style binding for background image can utilize computed properties or data for dynamic rendering

In my code, I am trying to pass an object that contains a string path for its background image. I have experimented with using data and computed properties, but so far I haven't had any luck getting them to work within the :style binding. However, if ...

What are the most effective techniques for utilizing JavaScript modules in both the Server and Browser environments?

Currently, I am in the process of developing a JavaScript project that utilizes NodeJS. There are certain objects that need to be shared between the client and server side. I attempted to employ the module system in Node, but struggled to find an appropria ...

Mapping memory for FirefoxOS is like equivalent strides

Is there a way to create a memory mapped file in FirefoxOS, Tizen or other pure-JS mobile solutions? In the scenario of a mobile browser where you have large amounts of data that can't fit in RAM or you prefer not to load it all at once to conserve R ...

How can I create a carousel-style container in HTML that functions similarly to the one on Upwork?

Is there a way to transform my existing container into a carousel similar to the one on Upwork? https://i.sstatic.net/dJZjy.png I am looking to convert my current layout into a carousel, just like the example image provided: .flex-container { displa ...

When a vertical scroll bar appears, the React + MaterialUI Menu shifts to the left by 15px with a bouncing layout

I integrated a Material-UI vertical menu into my application and encountered an issue when a vertical scrollbar appeared. In this scenario, the menu shifted 15px to the left, creating an unwanted blank space alongside the scrollbar. Here's the Code S ...

Encountering a RuntimeError during the integration of Angular Js in Rails with ExecJS

Currently, I'm working on integrating Angular Js into a Rails Project and I've been following the tutorial provided at . However, after completing all the steps, I encountered the following error: https://i.sstatic.net/ehYCb.png I've searc ...

What causes delayed state updates in React/NextJS until another state is updated or a fast refresh occurs?

UPDATE: Version 13.3.0 is coming soon! In my code, I have a state variable named localArray that I need to update at a specific index. To achieve this, I decided to create a temporary array to make modifications and then set the state with the updated val ...