我正在尝试.selected
使用 jquery 向我的导航菜单添加一个状态。我可以看到它正在努力工作,但说到底,风格并没有“停留”。点击后它应该是白色的。
HTML:
<ul id="coolMenu">
<li class="end"><a href="index.html"></a></li>
<li class="mid"><a href="products.html">products</a>
<ul class="mama">
<li class="uno"><a href="http://www.preworkoutforwomen.com"
onclick="_gaq.push(['_link', 'http://www.preworkoutforwomen.com']); return false;">Athena PreWorkout</a></li>
</ul>
</li>
<li class="midx"><a href="unico_fitness_blog.html">u.blog</a> </li>
<li class="midx"><a href="unico_athletes.html">athletes</a></li>
<li class="midx"><a href="aboutus.html">about us</a></li>
<li class="midx"><a href="contact.html">contact</a> </li>
<li class="shop"><a href="http://mgfyb.pkhqw.servertrust.com/">shop</a> </li>
</ul>
CSS:
#coolMenu {
list-style: none;
float:left;
padding-left:7.5px;
padding-right:0px;
position:relative;
}
#coolMenu ul {
-webkit-box-shadow: 0px 3px 3px 0px #4a4a4a;
border-bottom-left-radius:5px;
-moz-border-bottom-left-radius:5px;
-moz-box-shadow: 0px 3px 3px 0px #4a4a4a;
box-shadow: 0px 3px 3px 0px #4a4a4a;
}
#coolMenu .selected {
background-position:bottom !important;
color:black !important;
}
#coolMenu li {
width:145px;
height:48px;
display:inline-block;
float:left;
background-image:url(../images/misc/images/retina-sprite_03.png);
-webkit-background-size: 750px 150px;
-o-background-size: 750px 150px;
-moz-background-size: 750px 150px;
background-size: 750px 150px;
background-position: -301px -1px;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
#coolMenu > li.end {
border-bottom-left-radius:7px;
-moz-border-bottom-left-radius:7px;
border-top-left-radius:7px;
-moz-border-top-left-radius:7px;
background-position: -601px -1px;
text-align:center;
}
#coolMenu > li.shop {
text-align:center;
border-left-style:ridge;
border-left-color:#333;
border-left-width:thin;
border-bottom-right-radius:7px;
-moz-border-bottom-right-radius:7px;
border-top-right-radius:7px;
-moz-border-top-right-radius:7px;
}
#coolMenu > li.mid {
text-align:center;
border-left-style:ridge;
border-left-color:#333;
border-left-width:thin;
}
#coolMenu > li.midx {
text-align:center;
border-left-style:ridge;
border-left-color:#333;
border-left-width:thin;
}
#coolMenu li a {
display: block;
height: 2.4em;
line-height: 2.1em;
padding: 0px;
text-decoration: none;
}
#coolMenu uno,dos,tres a {
display: block;
height: .5em;
line-height: 1em;
padding: 0px;
text-decoration: none;
}
#coolMenu ul {
position: absolute;
display: none;
z-index: 999;
padding: 0px;
}
#coolMenu ul li {
}
#coolMenu ul li a {
}
#coolMenu li:hover ul.noJS {
display: block;
}
Javascript:
$(document).ready(function(){
$("#coolMenu li").click(function() {
// First remove class "active" from currently active tab
$("#coolMenu li").removeClass('selected, end, mid, midx, shop');
// Now add class "active" to the selected/clicked tab
$(this).addClass("selected");
});
});