<html>
<head>
<style>
#image
{
src: url(gfk_money_over.gif);
}
</style>
</head>
<body>
<img id="image" />
</body>
</html>
[web] using css to change source image
is something like this possible?
You can't do something like this in CSS. You'll need javascript to do the job:
document.getElementById('image').src = "gfk_money_over.gif";
Looks to me like you could just create a div with the desired image as a background, but I'm not seeing the advantage of that, as it still isn't dynamic.
Quote:Original post by KazgorothYou can do this with the image tag as well, as long as you give it an invisible gif or png as a source. Still strange, perhaps the OP could try and explain why he's doing things this way.
Looks to me like you could just create a div with the desired image as a background, but I'm not seeing the advantage of that, as it still isn't dynamic.
the reason is because my html is dynamic whereas my css is not.
and because this is for a menu, one of the table entries already uses a background image, whereas the header and footer for the table do not.
as you can see I want to keep the data in one place (either css file or menu arguments).
using an empty div tag doesn't work, and you also need a fixed image size for transparent image.
it doesn't matter any more though because I've simply inlined the above css data inside the generate_menu function.
and because this is for a menu, one of the table entries already uses a background image, whereas the header and footer for the table do not.
generate_menu("menu","menu-header.png","menu-footer.png",$linkslist);td.menuitems{ background-image: url(menu-bg.png);}
as you can see I want to keep the data in one place (either css file or menu arguments).
using an empty div tag doesn't work, and you also need a fixed image size for transparent image.
it doesn't matter any more though because I've simply inlined the above css data inside the generate_menu function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement