简体   繁体   中英

How can I prevent Internet Explorer from adding padding to buttons when pressed?

I have designed my submit buttons using CSS. In any Webkit or Gecko browser it works perfectly, but Internet Explorer 9 adds padding to the button's text when it is pressed down. In addition, you can see this stupid dotted border. It looks like this then:

http://img6.imagebanana.com/img/tkp7l8m3/button.png

The special background image which I have specified in CSS for input:active is only shown in IE, if the button is clicked in the very thin area between the button's border and this dotted border. If the button is clicked in the middle it keeps the hover-background although it is pressed down.

Can anyone help me remove this extra padding and the dotted border?

Thanks in advance

Qoguth

To get rid of the dotted border you can use pure CSS:

button { outline: none; }

As for padding when clicked, I fear it's part of the internal browser behavior that can't be changed.

You could try:

/* Swap 1px 6px for your desired top+bottom and left+right padding. */
button { padding: 1px 6px; }
button:active { outline: none; padding: 1px 6px; }

Presuming you actually want padding and not some other property.

Both of the answers given so far are incorrect in an important way. You should only hide the keyboard focus outline on:active, hiding it on:focus too hurts keyboard navigation.

button:active { outline: none; }

As has been stated, the increase in top-left padding is not overridable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM