I know that I cannot change the srctag attribute <img>using CSS. But is it possible to hide the image from the src attribute and instead set the background image in the tag <img>?
src
<img>
I thought something like this: moving the actual image using padding / text, etc. out of sight and after that setting the background image of the img tag, so it looks like another image.
Js is not an option, as it relates to existing page templates.
You can do this by pointing img src to the empty 1x1 gif image.
, div, src -. ( , , .)
, background-image.
UPDATE
, background-position. :
, 50 , , , . , css .
img { background: url(sprite.jpg) 0 0 no-repeat; } img:hover { background: url(sprite.jpg) -50px 0 no-repeat; }
:
img#someid { display: none; }
( , ) .
, " src", / , , CSS ( ), , , . CSS. - JS, JS . , MySQL, PHP, .
img div padding/margin display img ( js), div.
But honestly, if you take the trouble to do this, you should just swap src images via js.