Skip to content Skip to sidebar Skip to footer

How To Make :active State Work In Ie?

I have a button in my html form and need to change it's background image when it is clicked using css. it works perfect in FF but it seems that IE doesnt support :active state. H

Solution 1:

This is a known bug in earlier versions of IE (I think they solved it in IE8). I usually solve this (as well as the corresponding "hover" problem) with javascript. I attach two event handlers to the element -- "mousedown" to set an additional class (something like "button-active") and "mouseup" to remove the class. In jQuery it would be something like this:

$('.button').mousedown(function() { $(this).addClass('button-active'); });
$('.button').mouseup(function() { $(this).removeClass('button-active'); });

Then, just add that class to the css rule, like so:

.button:active, .button-active {
    background-position: center bottom;
}

A little ugly, yes, but what do you expect -- it's Internet Explorer. It can't be pretty.

Post a Comment for "How To Make :active State Work In Ie?"