使用 css 出现悬停图像时隐藏背景图像
我使用 CSS 进行悬停,它可以工作,但是悬停图像允许背景图像 (pic_normal
) 在图像 (pic_hover
) 后面显示为透明。
如何在鼠标悬停时仅显示悬停图像?
HTML
<img id="first" src="images/clients/pic_normal.png" />
CSS
#first img:hover {
background-image: url("/images/clients/pic_hover.png");
background-repeat: no-repeat;
}
I am using CSS for hover and it works, but the hover image allow the background image (pic_normal
) to display like transparent behind the image(pic_hover
).
How to display only the hover image when mouse over on it?
HTML
<img id="first" src="images/clients/pic_normal.png" />
CSS
#first img:hover {
background-image: url("/images/clients/pic_hover.png");
background-repeat: no-repeat;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 CSS 按预期工作得很好 - 它更改了
img
元素的背景。将pic_normal.png
视为元素的内容(例如一些文本)。当您更改背景时,内容不会改变。试试这个 - http://jsfiddle.net/WvKye/
Your CSS works just fine as intended - it changes the background of your
img
element. Think about thepic_normal.png
as the content of your element (e.gg. some text). When you changing the background the content doesn't change.Try this instead - http://jsfiddle.net/WvKye/
使用这个:
Use this:
我认为你需要一些 javascript
使用 Jquery 你可以这样做
I think u need some javascript for that
Using Jquery u can do like this