gpt4 book ai didi

javascript - 从背景图像淡化到悬停

转载 作者:行者123 更新时间:2023-11-27 22:30:57 25 4
gpt4 key购买 nike

我想将我的第一个背景图像淡化为应该在悬停时使用的图像,然后在用户移开鼠标后再次关闭。可以使用 jQuery。

这是我目前所拥有的:

    <ul style="top: -70px; display: block; padding-left: 205px;" id="cats-menu" class="nav superfish sf-js-enabled">
<a href="http://www.ballpointtech.com/category/guides/"></a><li id="li_guides" onclick="window.location = 'http://www.ballpointtech.com/category/guides/';"><a href="http://www.ballpointtech.com/category/guides/"> </a></li>

<a href="http://www.ballpointtech.com/category/news/"></a><li id="li_news" onclick="window.location = 'http://www.ballpointtech.com/category/news/';"><a href="http://www.ballpointtech.com/category/news/"> </a></li>
<a href="http://www.ballpointtech.com/category/reviews/"></a><li id="li_reviews" onclick="window.location = 'http://www.ballpointtech.com/category/reviews/';"><a href="http://www.ballpointtech.com/category/reviews/"> </a></li>
<a href="http://www.ballpointtech.com/category/tipstricks/"></a><li id="li_tipstricks" onclick="window.location = 'http://www.ballpointtech.com/category/tipstricks/';"><a href="http://www.ballpointtech.com/category/tipstricks/"> </a></li>
</ul>

<style type="text/css">
#li_guides {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/Guides-Still1.png');
width:130px;
height:92px;
}
#li_guides:hover {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/Guides-Rollover1.png');
}
#li_guides:active {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/Guides-Click2.png');
}
#li_reviews {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/Reviews-Still.png');
width:130px;
height:92px;
}
#li_reviews:hover {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/Reviews-Rollover.png');
}
#li_reviews:active {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/Reviews-Click.png');
}
#li_news {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/News-Still.png');
width:130px;
height:92px;
}
#li_news:hover {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/News-Rollover.png');
}
#li_news:active {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/News-Click.png');
}
#li_tipstricks {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/tipstricks-still.png');
width:130px;
height:92px;
}
#li_tipstricks:hover {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/tipstricks-rollover.png');
}
#li_tipstricks:active {
background-image:url('http://www.ballpointtech.com/wp-content/uploads/2010/09/tipstricks-click.png');
}
</style>

哎呀,无法正确设置格式...

最佳答案

Here's a good start I put together in jsbin .我只连接了新闻图标作为演示。它不是防弹的,因为在转换完成之前离开元素会使元素处于错误状态,但我不知道如何解决这个问题。 jquery 可能有比 fadeOut/fadeIn 更好的方法为了这份工作。您还需要制作 :active背景! important这样图片在点击时始终可见,而我在保存之前忘记这样做了。

你也不能有<a><li> 外悬挂的元素元素。建立链接display:block所以它们占据了列表项内的空白空间,然后你就可以把这些 hacky onclick="window.location..." 扔掉了。 .

关于javascript - 从背景图像淡化到悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3771728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com