Reputation: 11
#help {height: 127px; width: 127px}
#help:hover {content: url('LINK'); height: 127px; width: 127px}
<a href="link"><img src="imagelink" id="help"></a>
This works fine for me, but only on Chrome. Doesn't seem like it works on Firefox, the "hover" image doesn't appear.
Upvotes: 1
Views: 420
Reputation: 1855
Use right metod, it set image trough background-image and change him state for hover
Upvotes: -1
Reputation: 116
Just adding to Ballu's answer above. This works in Firefox too.
#help {background: url(http://placekitten.com/127/127);height: 127px; width: 127px; display: inline-block}
#help:hover {background: url('http://lorempixel.com/127/127/')}
<a href="link" id="help"></a>
Upvotes: 1
Reputation: 21672
The CSS content
attribute can only be used with Pseudo Elements like ::before
and ::after
.
Per MDN:
The content CSS property is used with the ::before and ::after pseudo-elements to generate content in an element. Objects inserted using the content property are anonymous replaced elements.
Initial value: normal
Applies to: ::before and ::after pseudo-elements
For a fix, as Ballu suggests in his answer, you may want to make the image a background-image
in CSS instead of an <img>
element in the HTML. You can then change the background-image
attribute on :hover
instead of the content
attribute.
Upvotes: 3
Reputation: 9
Try with background not content.
#help:hover {background: url('LINK'); height: 127px; width: 127px}
Thanks
Upvotes: 1