Solved

Colorizing an Image using CSS (Filter?)

Posted on 2004-08-05
10
374 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
reposition hamburger icon to top of screen 5 45
Paper tearing animation 6 39
jQuery CSS Scroll Issue 3 30
Creating a slider 12 33
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
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 customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now