Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-21-2009, 10:53 PM   PM User | #1
poker298
New to the CF scene

 
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
poker298 is an unknown quantity at this point
color on top of image??

I have an image that is gray-scale, and I want to dynamically change the color using CSS. Is this possible?

#example {
background-image:url('gray_button.png');
}

I could change the opacity/transparency of the image. How do I "set" a color on Top of this image though?

Any help appreciated.
poker298 is offline   Reply With Quote
Old 10-21-2009, 11:18 PM   PM User | #2
jolly_nikki
New Coder

 
Join Date: Aug 2009
Posts: 94
Thanks: 0
Thanked 16 Times in 16 Posts
jolly_nikki is on a distinguished road
I am not sure if the image color can be changed using CSS.
But you can change the image on mouse over by setting the src attribute to different value using JavaScript. Or change the background of the image

Code:
<html>
	<head>
		<script>
			function changecolor(){ 
				document.getElementById("logo").setAttribute("class", "logo");
			}
			
			function changecolorback(){ 
				document.getElementById("logo").setAttribute("class", "");
			}
		</script>
		
		<style>
			
			.logo {
			    position:absolute;
			    background-color:blue;
			    opacity: 0.8;
			    z-index: 100;
			}
			
		</style>
	</head>

	<body>
			<img src = "box.png" onmouseover = "changecolor()" onmouseout = "changecolorback()" id = "logo" /> 
	</body>
</html>
jolly_nikki is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 AM.


Advertisement
Log in to turn off these ads.