开发者

How to change an image <img> on mouse rollover (hover)

开发者 https://www.devze.com 2023-02-15 19:20 出处:网络
How can I change an image (set using <img> tag, which is not a <div> or <some_selector> background, that can be easily solved by changing background or backgro开发者_Go百科und-image

How can I change an image (set using <img> tag, which is not a <div> or <some_selector> background, that can be easily solved by changing background or backgro开发者_Go百科und-image attribute on :hover in CSS) on mouse rollover (hover) like the favorite tag remove button in stackoverflow homepage, in which the (X) image becomes red on hover ?


HTML

<div id="css-image-swap-1">
<img id="swap-1" src="default-image-url" alt="CSS image swap" />
</div>

CSS

#css-image-swap-1{
    width:300px; height:150px; background:url(swap-image-url);
}
#css-image-swap-1 img:hover{
    opacity:0;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消