In this article, you'll learn how to create the rollover effect without using Java Script and without preloading images. You'll learn how to combine the "up", "over", and "down" images into a composite image, and how to use Cascading Style Sheets (CSS) to specify a position offset into the image in order to display the proper section for each button state.
Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

Create CSS Button Rollovers

A "rollover" is an effect produced when the user moves their mouse over a webpage element. The most common web page element to which a rollover effect is applied is a button, although the rollover effect is frequently applied to text links as well. The most common rollover effect is to make the button text and/or the button itself to appear to "light up" when the user moves their mouse pointer over it, and to make the button appear pressed when the user presses the mouse button while the mouse pointer is over the button.

A rollover effect is usually created using Java Script. You need three separate button images, one for the "up", "over", and "down" button states. Java Script functions assigned to the html image tag onMouseover, onMouseout, onMousedown, and onMouseup events swap the images. One problem with this approach is the time delay required to download the replacement image. The replacement images could be preloaded, but that increases the delay before the webpage displays in the user's browser. Another problem is that some users have Java Script disabled in their browsers.

In this article, you'll learn how to create the rollover effect without using Java Script and without preloading images. You'll learn how to combine the "up", "over", and "down" images into a composite image, and how to use Cascading Style Sheets (CSS) to specify a position offset into the image in order to display the proper section for each button state.

- In CSS the three button states are referred to as "normal", "hover", and "active".

Creating the Button Image

The first step in creating a button image is to choose the background graphic or texture for the button. Trim the graphic to the desired size and make three copies of it. use an image processing application to "buttonize" the fist two copies. If you don't have an image processing application, click here to download the freeware image processing application Harmwave. Shown below is a trimmed background graphic before and after it's buttonized.

Before buttonization After buttonization

Make the "hover" image appear to light up by using an image processing application to increase the brightness of the image, as shown below.

After brightness increase

To make the "active" button image, use an image processing application to "flip" or "reflect" the image vertically and horizontally. Then "buttonize" the image. Then flip the image back to it's original position. This reverses the sides of the button showing light and shadow. You might also decrease the brightness of the image to enhance the "pressed" effect.

After brightness decrease

- Although Harmwave provides over 50 image processing effects, unfortunately it's not great for reducing the brightness of an image. If you don't have an image processing application for that can reduce the brightness of an image, click here to download Paint Shop Pro Version 4.12 Shareware.

- If you're not experienced with image processing applications, you might need to experiment to get the images for the rollover effect perfect.

After you have completed the images of the three button states, carefully paste them into one image, with the normal image on top, followed by the hover and active images, as shown below.

Composite button image



RSS Feed RSS Feed


Follow Stephen Bucaro Follow @Stephen Bucaro


Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2016 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268