background color not changing on hover css

user3131961

I used this for styling navigation bar of my webpage but the color is not changing on hover

.nav {
    list-style-type:none;
    margin:0;
    padding:0;
    overflow:hidden;
}

.nav li {
    float: left;
}

.nav li a:hover,.nav li a:active {
    background-color:#7A991A;
}

.nav li a:link,.nav li a:visited {
    display:block;
    width:9em;
    font-weight:bold;
    color:#FFFFFF;
    background-color:#98bf21;
    text-align:center;
    padding:4px;
    text-decoration:none;
    text-transform:uppercase;
}

HTML code:

<ul class = "nav">
        <li><a href="index.html">Home</a></li>
        <li><a href="products.html">Our Products</a></li>
        <li><a href="aboutus.html">Contact us</a></li>
</ul>

can someone suggest what I did wrong?

Nabil Kadimi

Either add !important here:

.nav li a:hover,.nav li a:active {
    background-color:#7A991A !important;
}

Or move the properties for :hover (and :active) after those for :link.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

background color not changing on hover css

From Dev

Changing background color of Ionic list item on hover in CSS

From Dev

CSS - Changing background on hover not working

From Dev

CSS: Change Background Color on Hover

From Dev

CSS: Change Background Color on Hover

From Dev

Changing li:hover background color with Bootstrap

From Dev

CSS changing (transitioning) background color

From Dev

CSS Hover Text Changing Color With Button

From Dev

On hover color not changing using LESS css

From Dev

Changing color of text in div on hover? - CSS

From Dev

Changing color of text in div on hover? - CSS

From Dev

Fade background color of button on hover css

From Dev

CSS Hover change background color on other labels

From Dev

CSS - Change button background color on hover

From Dev

CSS hover transition / transform background color scale

From Dev

fadein background color on hover using CSS

From Dev

Change link CSS color without changing :hover color

From Dev

Changing HTML button tag background color with css?

From Dev

Changing background color of button with inline CSS

From Dev

Changing background color on input focus with css alone

From Dev

changing css background color with javascript variables

From Dev

Automatic changing background color loop (jQuery/css?)

From Dev

changing css background color with javascript variables

From Dev

changing css background-color property

From Dev

Background color is not changing after adding CSS

From Dev

Radio button not changing background color HTML/CSS

From Dev

Automatic changing background color loop (jQuery/css?)

From Dev

CSS list menu is not changing background-color

From Dev

Changing background color based on browser size in CSS

Related Related

HotTag

Archive