Better Rollover with CSS & jQuery
My third pass at a rollover and my favorite solution by far. This one uses minimal code, avoids flickering while also decreasing load times.
Basically create each image or button with active and over states next to one another. For for our example, side by side. We apply the image as a background, defining the width of the space as half our image (so only the active state shows). Then when the use hovers, we reposition the background to show the active state only.
$(function() { $("#teasers div").hover(function() { $(this).css('background-position', 'top right'); }, function() { $(this).css('background-position', 'top left'); }); });Tags: better, css, rollover, sliding