当容器 div(在本例中为 #header)的不透明度为 0.5 时,我想在链接列表上覆盖我的 CSS 悬停操作。我很难过。
这是我的 jQuery:
jQuery(window).scroll(function() {
if(jQuery(window).scrollTop() > 200) {
jQuery("#header").css('opacity', '0.5');
} else {
jQuery("#header").css('opacity','1');
}
});
if(jQuery("#header").css("opacity") != 1){
jQuery("#nav li a").hover(function(){
jQuery(this).css("color","rgba(63, 131, 202, 1)");
});
}
这是我的 CSS:
#nav li a {
color:rgba(63, 131, 202, 1);
transition: color 1s;
-webkit-transition: color 1s;
-o-transition: color 1s;
-moz-transition: color 1s;
}
#nav li a:hover {
color:rgba(63, 131, 202, 0.7);
transition: color 1s;
-webkit-transition: color 1s;
-o-transition: color 1s;
-moz-transition: color 1s;
}
我也尝试过在 jQuery 中用 none 覆盖每个转换,但它不起作用。我怎么能这样做?当不透明度不是 1 时,我应该尝试覆盖所有非悬停属性,然后像上面那样覆盖悬停属性吗?不知道该怎么办。