如何让css悬停在图像上而不影响图像

时间:2013-03-11 06:58:01

标签: hover

看图像...... 要理解; P

这是我使用的代码

.img1 {
background-image: url('img1.png');
width: 381px;
height: 187px;
background-repeat: no-repeat;
float: left;}

.img1:hover {
    background-image: url('imghover.png');
    width: 381px;
    height: 115px;
    background-repeat: no-repeat;
}

但它正在影响img1 我希望它出现在img1上方而不影响它

我很抱歉

看到这是一个例子 https://dl.dropbox.com/u/35904623/css.gif

+ 另一个

https://dl.dropbox.com/u/35904623/css2.gif

1 个答案:

答案 0 :(得分:1)

在悬停时,您将高度设置为381px,margin-top设置为-116px

height: 381px;
margin-top: -116px;

哪会影响图片1。

相关问题