Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Colorizing an Image using CSS (Filter?)

Posted on 2004-08-05
10
376 Views
Last Modified: 2012-06-21
Dear All,

I would like to display an image on a page that is colorized so that it looks blue for example, but when the user mouseovers on it it changes color. Is there a way of doing this? Perhaps an IE specific filter can achieve the colorization of images?

Any help much appreciated.

Ben.
0
Comment
Question by:webtechy
10 Comments
 
LVL 17

Expert Comment

by:mreuring
ID: 11725144
Allas I don't have the time to look into this further, as it should be relatively easy, but in the mean time, some links for reading up on your knowledge perhaps :)
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/filter.asp how to do filters in IE only css
http://msdn.microsoft.com/workshop/author/filter/reference/reference.asp the selection of possible filters you can apply...

Good luck,

 Martin
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11727088
Another reference for filters that is from the same site (but a different page) as mreuing's links is :
http://msdn.microsoft.com/workshop/author/filter/filters.asp

THe problem with filters in CSS that I have seen is that they are not supported very well.

One easy way which doesn't involve CSS is to have two images and use javascript to change the image on mouseover.
0
 
LVL 3

Accepted Solution

by:
hyperslug earned 250 total points
ID: 11727190
Here's a quick and dirty solution using alpha:

<style>
      .alpha {
            filter: alpha(opacity=50);      /* IE */
             -moz-opacity: 0.5; /* Mozilla */
      }
      .red {
            background: red;
            width: 0%;
      }
      .blue {
            background: blue;
            width: 0%;
      }
</style>

<div class="blue" onmouseover="this.className='red'" onmouseout="this.className='blue'">
      <img src="PICTURE.jpg" class="alpha"></div>
      
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:webtechy
ID: 11727708
Hi guys,

I'm afraid I don't have that much control over the code to add onmouseout's or some more clever JavaScript etc. I did _think_ about that though and seems the closest you can do.

Have looked through the Microsoft filters and can't seem to find anything that really applies unfortunately. Not too worried about browser support as not "mission critical" if doesn't work - just a nice to have ...

Cheers,

Ben.
0
 
LVL 3

Expert Comment

by:hyperslug
ID: 11728168
Ok, then use an <A> tag, (doesn't seem to work right in mozilla though):

---------------------------------------------------------------------------------------
<style>
      .alpha {
            filter: alpha(opacity=50);     /* IE */
            -moz-opacity: 0.5; /* Mozilla */
            border: 0px;
            cursor: default; /* discourage ppl from clicking */
      }
      a.colorize { background: red; }
      a.colorize:hover { background: blue; }
</style>

<a href="#" class="colorize"><img src="/graphics/kids.jpg" class="alpha"></a>
0
 
LVL 2

Expert Comment

by:Joakim_
ID: 11750946
Filters sucks, and they are compatible with very few browsers, find an another solution.
0
 
LVL 2

Author Comment

by:webtechy
ID: 11751014
As I say, not too fussed about compatibility as it doesn't really matter too much anyway ...
0
 
LVL 3

Expert Comment

by:hyperslug
ID: 11751929
Did the A tag method work?
0
 
LVL 2

Author Comment

by:webtechy
ID: 11751978
I didn't have the option of changing the code as such, although I did apply a similar technique elsewhere on the site. Although it's not colorization in Paint Shop Pro terms (as the image is just composed on a range of blues for example), it does tint the image so that it matches the general branding of the site.
0
 
LVL 2

Author Comment

by:webtechy
ID: 11751985
(I did try img:hover on the off-chance that that may work ;-))
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question