Simon Willison’s Weblog

Subscribe

CSS image rollovers

17th August 2002

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.

Next: Today's pleasant surprise

Previous: Working on my blog

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