有一个没有背景的链接和一个css规则,它可以在悬停时更改背景。
父bg是白色的,链接到悬停- .png背景图像.
从白色到背景图像,如何缓慢地做一个悬停效果呢??
谢谢。
li a {}
li a:hover { background: url(image.png) 0 0 no-repeat; }
发布于 2009-04-30 20:38:47
CSS
li {
background: #FFF;
}
li a {
opacity: 0;
display:block;
height:200px; /* Image height */
width:200px; /* Image width */
background:transparent url(image.png) top left no-repeat;
}
JavaScript
$(function(){
$("li a").hover(function(){
$(this).stop();
$(this).animate({"opacity":1}, "slow");
}, function(){
$(this).stop();
$(this).animate({"opacity":0}, "slow");
});
});
请参阅http://docs.jquery.com/Effects
发布于 2009-04-30 20:32:03
脑海中浮现的一件事是战略性地放置具有背景背景集的图层,以及在彼此之上放置颜色为实心的图层,并在悬停时动画正确事物的不透明度属性(如果顶部的东西变得透明,底部的东西就会通过)。
发布于 2011-12-07 12:00:05
透明在IE中无效。
https://stackoverflow.com/questions/808882
复制相似问题