我有以下代码来悬停它后生成图像:
$(".myImage").hover(function () {
$(this).find('img').stop() /* Add class of "hover", then stop animation queue buildup*/
.animate({
width: '560px', /* Set new width */
height: '174px', /* Set new height */
padding: '20px'
}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
}, function () {
$(this).find('img').stop() /* Remove the "hover" class , then stop animation queue buildup*/
.animate({
width: '140px', /* Set width back to default */
height: '44px', /* Set height back to default */
padding: '5px'
}, 400);
});
但问题是,当图像增长时,它会显示在项目左侧的另一个图像(恰好是背景图像)后面。 。显示在该图像上的另一个图像上的css是:
.otherImage {
background: url("/Content/Images/main1.png") repeat scroll 0 0 transparent;
display: block;
height: 506px;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
position: relative;
width: 527px;
z-index: 0;
}
如何让调用动画的图像悬停在此背景图像上?
以下是调用动画的图像的原始css(从firebug复制)
element.style {
display: inline-block;
height: 44px;
left: 0;
margin-left: 0;
margin-top: 0;
padding: 5px;
top: 0;
width: 140px;
}
.myImage img {
height: 44px;
width: 140px;
z-index: 999;
}
a img {
border: medium none;
}
答案 0 :(得分:1)
如果您动画的对象是position: absolute
,那么您可以将其z-index
设置为比其他对象更高的值,它将位于顶部。
如果不是position: absolute
,那么我们必须在这两个对象上看到相关的HTML标记和所有CSS样式,以了解您的选项。