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!

Welcome to 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 Advertise on Bucaro TecHelp Advertise Here RSS News Feeds News Feeds

HTML5 Solutions: Essential Techniques for HTML5 Developers

Essential Techniques for HTML5 Developers

HTML5 brings the biggest changes to HTML in years. Web designers now have new techniques, from displaying video and audio natively in HTML, to creating realtime graphics on a web page without a plugin.

This book provides a collection of solutions to all of the most common HTML5 problems. Every solution contains sample code that is production-ready and can be applied to any project.

Click Here

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

Web Design Sections

CSS3: Visual QuickStart Guide (5th Edition)

With this book, readers can start with a tour of the stylesheet language, or skip ahead to any chapter of the book to look up specific tasks covering just what they need to know. This task-based, visual reference guide uses step-by-step instructions, and plenty of screenshots to teach beginning and intermediate users CSS.

Reader David Diez of Boston, MA says, "This book's strategy seems to be show an example, give a general explanation, provide a few key but brief tips, move on. The writing is clear and concise. ... I continue to be very pleased and impressed with the book. It's proving to be a helpful reference and everything in it is highly accessible. Click here for more information.


[Site User Agreement] [Advertise on This site] [Search This Site] [Contact Form]
Copyright©2001-2011 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268