Sign in to follow this  

[web] using css to change source image

This topic is 4592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is something like this possible?
<html>
<head>
	<style>
	#image
	{
		src: url(gfk_money_over.gif);
	}
	</style>
</head>

<body>
	<img id="image" />
</body>
</html>

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kazgoroth
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.
You 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.

Share this post


Link to post
Share on other sites
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.

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.

Share this post


Link to post
Share on other sites

This topic is 4592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this