Jquery背景/文本颜色淡入度
我在下面有一个Jquery脚本,它在悬停时会以背景色淡出。当背景像预期的那样淡出时,文本也淡入淡出,这是我不想要的。理想情况下,我只希望背景颜色淡入,而不是文本 任何帮助都将不胜感激。谢谢:) JqueryJquery背景/文本颜色淡入度,jquery,text,background,fade,Jquery,Text,Background,Fade,我在下面有一个Jquery脚本,它在悬停时会以背景色淡出。当背景像预期的那样淡出时,文本也淡入淡出,这是我不想要的。理想情况下,我只希望背景颜色淡入,而不是文本 任何帮助都将不胜感激。谢谢:) Jquery $(document).ready(function () { //Set the anchor link opacity to 0 and begin hover function $("#menu-sample-menu li a").hover(function ()
$(document).ready(function () {
//Set the anchor link opacity to 0 and begin hover function
$("#menu-sample-menu li a").hover(function () {
//Fade to an opacity of 1 at a speed of 200ms
$(this).fadeOut(0).addClass('hover').fadeIn(300);
//On mouse-off
}, function () {
//Fade to an opacity of 0 at a speed of 100ms
$(this).fadeOut(300)
.queue(function () {
$(this).removeClass('hover').fadeIn(0).dequeue()
});
});
});
HTML
包括,并设置
背景色
属性的动画。嘿,Joseph,谢谢您的回复。我一定要试一试。在此之前,为了将脚本保持在最低限度,是否有一种方法可以在不使用额外插件的情况下实现我想要的效果?@user2325396-您可以添加另一个绝对位置的元素来覆盖整个父元素,然后将其z-index
设置为-1,使其位于内容后面。您可以在JavaScript代码中淡出这些信息。Thx。如果我要使用彩色动画插件,你能提供一些关于Jquery代码外观的帮助吗?@user2325396-只需使用来制作背景
颜色的动画即可。
<nav id="access">
<ul id="menu-sample-menu" class="menu">
<li id="menu-item-198" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-198"><a href="http://www.threecell.com/demo/category/health-care-professional/">Health Care Professional</a>
</li>
<li id="menu-item-197" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-197"><a href="http://www.threecell.com/demo/category/web-designer/">Web Designer</a>
<ul class="sub-menu">
<li id="menu-item-199" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-199"><a href="http://www.threecell.com/demo/category/construction-worker/">Construction Worker</a>
</li>
</ul>
</li>
</ul>
</nav>
#access {
padding:0 20px;
background:#111;
box-shadow:0 0 7px rgba(0, 0, 0, .1);
}
#access ul {
float:left;
padding:0;
margin:0;
list-style:none;
font-weight:600;
text-transform:uppercase;
}
#access li {
position:relative;
float:left;
padding:0;
margin:0;
}
#access ul li:first-child {
padding-left:0;
}
#access a {
display:block;
padding:15px 24px;
color:#f0f0f0;
text-decoration:none;
}
#menu-sample-menu li {
color: black;
text-shadow: 0px 1px 4px #777;
background-color: green;
padding: 0 12px 0 12px;
}
#menu-sample-menu li a.hover {
background: orange;
}
#access li.current_page_item > a,
#access li.current-menu-item > a {
background: orange;
color: white;
text-decoration:none;
}
#access a span {
color:#999;
font-size:11px;
font-style:italic;
font-weight:normal;
line-height:1.62em;
text-transform:none;
}