【问题标题】:how can i make a css hover over image Without affecting the image如何在不影响图像的情况下使 CSS 悬停在图像上
【发布时间】:2013-03-11 06:58:00
【问题描述】:

看图... 理解;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

【问题讨论】:

  • “影响它”是什么意思?您正在更改图像 URL,因此它受到了影响。此外,由于链接中的两个图像似乎具有相同的纵横比,为什么要为 :hover 指定不同的高度?
  • @Osiris 抱歉,我给出了错误的代码,请在 ^ 上方再次检查示例

标签: hover


【解决方案1】:

悬停时,您将高度设置为 381 像素,将边距设置为 -116 像素

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

哪些会影响图像 1.

【讨论】:

  • 对不起,我给出了错误的代码,请在上面再次检查 ^ 示例
猜你喜欢
  • 2016-12-21
  • 1970-01-01
  • 2015-06-08
  • 2019-08-29
  • 2017-07-15
  • 1970-01-01
  • 1970-01-01
  • 2013-11-11
  • 1970-01-01
相关资源
最近更新 更多