Issues arise when trying to alter the attributes of the :hover pseudo-class

I'm having trouble changing the background-color of list items to black when hovering over them. However, changing the color itself is working fine.

.nav li {
  display: inline-block;
  height: 100%;
  padding: 0px 35px;
  border-width: 0 1px 1px 0px;
  border-color: white;
  border-style: solid;
  box-sizing: border-box;
  line-height: 37px;
  background: linear-gradient(rgb(81, 59, 192) 26%, rgb(183, 172, 237))
}

.nav li:hover {
  background-color: black;
  color: black;
}
<ul class="nav">
  <li>Lorem</li>
  <li>Ipsum</li>
  <li>dolor</li>
  <li>amet</li>
</ul>

Answer №1

The linear gradient is currently overlapped by the background color. To fully override the background, switch from using background-color to simply background.

Answer №2

The concept of the CSS background shorthand property encompasses various individual properties.

It's important to note that a linear-gradient serves as a type of background-image rather than a background-color.

If you set background-color: black, it might seem ineffective as it may be concealed by the background-image.

To view the color, eliminate the image by using background-image: none.

.nav li {
  display: inline-block;
  height: 100%;
  padding: 0px 35px;
  border-width: 0 1px 1px 0px;
  border-color: white;
  border-style: solid;
  box-sizing: border-box;
  line-height: 37px;
  background: linear-gradient(rgb(81, 59, 192) 26%, rgb(183, 172, 237))
}

.nav li:hover {
  background-color: black;
  background-image: none;
  color: black;
}
<ul class="nav">
  <li>Lorem</li>
  <li>Ipsum</li>
  <li>dolor</li>
  <li>amet</li>
</ul>

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

Prevent the overlap of the float right span with text using CSS

I'm currently using rickshaw and have a graph hover/annotation where a color swatch (defined with a <span>) is overlapping text within the same <div>. Check out my HTML code below: <div class="detail" style="left:250px"> <d ...

Tips for creating a wide mobile menu

I am attempting to make the mobile menu full width, but so far my efforts have been unsuccessful. #menu-main-2 { background-color:#FFFFFF !important; padding-left:15px; max-width: unset; width: 100%; } view mobile menu ...

Utilizing Selenium to extract data from a table and displaying the results

I am looking to scrape tables from a specific website, but I am new to automation with Selenium. Here is the code snippet that I have come up with after doing some research: from selenium.webdriver import Firefox from selenium.webdriver.common.by import By ...

Increasing the size of a card beyond the container using the CSS PRE tag

I am facing an issue with a card on my webpage. It contains a pre tag inside it, which is causing the size of the card to extend beyond its container, resulting in a horizontal scroll bar appearing. How can I make the content within the pre tag scroll hori ...

Check if the data-indices of several div elements are in sequential order using a jQuery function

Is there a way to implement a function in jQuery-ui that checks the order of div elements with data-index when a submit button is pressed? I have set up a sortable feature using jQuery-ui, allowing users to rearrange the order of the divs. Here is an exam ...

What is the best way to seamlessly replicate a small background image across a webpage?

Currently, I'm trying to set a page background image using the following CSS code: background:url(images/body_bg.jpg) repeat-x top; The issue is that the image size is not large enough to cover the entire webpage - it only appears as a thin strip. A ...

What could be causing my JSON product list to not load properly?

My list is not loading and I can't figure out why. I've included my json, jquery, and HTML below. The console isn't showing any errors, but the list is still blank. Any help would be greatly appreciated as I am new to working with json. Than ...

Is there a way to send all the results of a Flask database query to a template in a way that jQuery can also access

I am currently exploring how to retrieve all data passed to a template from a jQuery function by accessing Flask's DB query. I have a database table with customer names and phone numbers, which I pass to the template using Flask's view method "db ...

HTML/CSS: Maintain Hover-Over Pop Up Boxes in Position Until Another Element is Hovered Over

Seeking HTML code to maintain a hover-over pop-up box in position on an image map until another section of the image map is hovered over. For example, refer to my code below - when hovering over a country on the map, a pop-up box with information about a ...

Adjusting the width of row items in Angular by modifying the CSS styles

I am envisioning a horizontal bar with items that are all the same width and evenly spaced apart. They can expand vertically as needed. Check out the updated version here on StackBlitz https://i.sstatic.net/MFfXd.png Issue: I am struggling to automatica ...

Troubleshooting CSS Text Display on HTML5 Video for Mobile Devices

I am currently working on positioning text and a button over an HTML5 video without using media queries to address mobile display issues. The problem arises when using the car-image-overlay class from Bootstrap 4 to show the div containing the text over th ...

Enhance Your Cards with Hover Zoom Text

I'm looking to place some text in front of a card hover zoom effect, but currently it appears behind the zoomed image upon hover. <div style="margin-top: 50px;" class="container imgzoom"> <div class="row ...

Tooltip remains visible even after formatting in highcharts

I have successfully hidden the datalabels with 0 values by formatting them. However, after formatting the tooltips for 0 valued data in a pie chart, there is an issue where hovering over the 0 valued portion shows a white box as shown in the picture. I hav ...

Using ReactJS to toggle a div upon clicking

I am facing an issue with toggling a div by clicking on text within a toggle bar. I am in the process of recreating a WordPress website template in React JS that was originally built using bootstrap. You can view the original template here. So far, I have ...

JavaScript Comparison of Numerical String Syntax

I created an HTML function to determine the maximum number, but it is returning incorrect results. Could someone please point out what I am doing wrong? Thank you! The code is as follows: <!DOCTYPE html> <html> <head> <meta charset=& ...

What is the Best Way to Create a Form Inside a Box?

Hello there! I am trying to create a form underneath the box labeled "New Referral," but I'm having trouble figuring it out. I would like to include sections for first name, last name, date of birth, phone number, email, and address under the box. Any ...

Using Bootstrap's card component, design a grid layout for your website

I am attempting to construct a grid using the Bootstrap 4 card component. After reviewing the documentation and utilizing the card-deck feature, I aim to have each row consist of two columns with the behavior similar to col-12 col-md-6. Additionally, the s ...

Enhancing the appearance of a JSX component in React

I have a segment of code within my project that calculates a specific percentage and displays it on the dashboard. <text className="netProfit-circle-text" x="50%" y="50%" dy=".2em" textAnchor="middl ...

Implementing a redirection of Dojo Data grid cell values to a different destination

I am working with a Dojo data grid that contains 10 rows (cells) of values. When the first row is clicked, I need it to redirect to another HTML page and carry along the values from the first row. Can you assist me in achieving this functionality? ...

Is it possible to set spacing between the rows of an HTML table without also setting spacing for the columns?

Is there a way to add spacing between the rows of a table without affecting the columns? ...