Reputation: 53
Maybe fresh eyes can see where i am going wrong with this but i want the active menu item to have a different style...
HTML:
<div id="menu">
<ul>
<li id="active"><a href="#">Home</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
And my CSS:
#menu ul {list-style-type: none;height: 40px;float: left;margin-top: 43px;margin-left:-32px;}
#menu li {
float: left;
}
#menu li #active {
background: url(../images/menu-bg-hover.png) no-repeat;
color: #ffffff;
}
#menu li a {
background: url(../images/menu-bg.png) no-repeat;
display: block;
width: 100px;
height: 40px;
text-decoration: none;
font-size: 16px;
color: white;
margin: 0 auto;
text-align: center;
padding-top: 10px;
color:#424242;
font-family: "Helvetica", Arial, sans-serif;
}
Upvotes: 0
Views: 18291
Reputation: 9758
Just fix the style like this:
#menu li#active {
background: url(../images/menu-bg-hover.png) no-repeat;
color: #ffffff;
}
You had written it as #menu li #active
rather than #menu li#active
.
Upvotes: 2
Reputation: 632
Remove
#menu li #active {
background: url(../images/menu-bg-hover.png) no-repeat;
color: #ffffff;
}
ADD
#menu #active a{
background: url(../images/menu-bg-hover.png) no-repeat;
color: #ffffff;
}
Upvotes: 0
Reputation: 2034
Update your CSS to #menu li#active a
and place it below #menu li a
. This will ensure that the styling overrides the default styles, in this case the background image and text color.
#menu li #active
forces the browser to locate a child element with the id active
under li
.
Upvotes: 0