Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent <button> from shifting during click in IE

When you have a simple element in a page and click it (hold down the mouse during click to see the effect) in IE8/9 then the button shifts a little down and to the right.

I'm assuming this is part of the default IE style. Is there anyway to prevent this behavior?

http://jsfiddle.net/tmcconechy/hqm59/

like image 525
Tim Avatar asked Apr 24 '12 20:04

Tim


3 Answers

You can stop the text moving in IE button:

button:active span, button:focus span {
    position:relative;
    top: 0;
    left: 0;
}

<button><span>no move</span></button>

http://jsfiddle.net/dQVA7/

like image 197
user3144038 Avatar answered Nov 05 '22 05:11

user3144038


Put your text on a <span> and position:relative in it, it'll fix.

button span{
    position: relative;
}

No need for top and left definition.

like image 25
teefars Avatar answered Nov 05 '22 03:11

teefars


You can apply some styles to the button. button{ margin: 0px; padding: 0px;}

like image 1
Mark Hulbrock Avatar answered Nov 05 '22 04:11

Mark Hulbrock