出于某种原因,我只是无法让悬停效果工作
HTML:
<div id="navbarcontainer">
<ul>
<li id="left" class="current">
<a id="current">Home</a></li>
<li class="dependant1">
<a id="dependant1">Services</a></li>
<li id="right" class="dependant2">
<a id="dependant2">Contact</a></li>
</ul>
</div>
CSS:
#navbarcontainer {
margin: 0;
padding: 0;
height: 50px;
background: #01216D;
}
#navbarcontainer ul {
clear: both;
margin: 0;
padding: 0;
list-style: none;
}
#navbarcontainer li {
display: inline-block;
height: 50px;
width: 100px;
list-style: none;
text-align: center;
-moz-transition: .5s;
-o-transition: .5s;
-webkit-transition: .5s;
transition: .5s;
/* Firefox 4 */
/* Opera */
/* Safari and Chrome */
}
#navbarcontainer ul li a {
text-decoration: none;
line-height: 50px;
width: 100px;
font-size: 20px;
font-family: Calibri;
cursor: pointer;
}
#left {
margin-right: 40px;
margin-left: 20px;
}
#right {
margin-left: 40px;
}
.current {
background: #fff;
}
#current {
color: #01216D;
font-weight: bold;
}
#dependant1, #dependant2 {
color: #fff;
}
jQuery:
$("#dependant1").hover(function () {
$('.dependant1').stop().animate({background: '#fff' }, "slow");
$('#dependant1').stop().animate({color: '#01216D', 'font-weight': 'bold'}, "slow");
}, function () {
$('.dependant1').stop().animate({ background: 'none' }, "slow");
$('#dependant1').stop().animate({color: '#fff', 'font-weight': 'normal'}, "slow");
});
我觉得它与jQuery有关,但我在document.load中有它,所以我不明白为什么它不起作用。