Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

CSS image rollovers

CSS Image Rollovers describes a brilliantly simple technique for creating the effect of an image rollover using only one image and no javascript. The effect works by creating a gif with a transparent background, then using a :hover pseudo class to change the background colour of the the containing area. Pretty straight forward so far, but the clever part is that by making the transparent part of the gif an interesting shape (placing it around the outline of a shape in the image for example) you can give the impression of displaying a different image entirely.

This is CSS image rollovers by Simon Willison, posted on 17th August 2002.

View blog reactions

Next: Today's pleasant surprise

Previous: Working on my blog

4 comments

  1. Great site Simon. I've always liked these buttons also, no images and clean code. Note the use of padding to make the button text appear to depress.

    CIAwallst - 17th August 2002 16:00 - #

  2. For got the link... http://www.htmlcenter.com/tutorials/tutorials.cfm/ 154/CSS/

    CIAwallst - 17th August 2002 16:01 - #

  3. Nice link. There was a similar feature in ALA sometime ago. Just in case someone doesn't know it http://www.alistapart.com/stories/rollovers/index. html

    mort - 17th August 2002 20:25 - #

  4. Oohh this is cool. I've made a pure css image rollover a while back (a bit more complex but still easily usable), that does the entire job of any JS rollover, and is fully accessible. Look for an article about it at www.Evolt.org sometime this week. BTW, i love your blog. Chock full of interestin' tidbits, and two scoops of raisins.

    The Student - 18th August 2002 08:39 - #

Comments are closed.

Previously hosted at http://simon.incutio.com/archive/2002/08/17/cssImageRollovers

A django site