Solved

Colorizing an Image using CSS (Filter?)

Posted on 2004-08-05
10
377 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
[X]
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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I select this logo using CSS? 6 43
Hiding Adsense on Mobile Devices 2 51
bootstrap wrap text 1 36
Drop Down not working in mobile- Bootstrap 14 34
Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
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 style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

726 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