Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jagged Button edges in Internet Explorer

How do you remove the jagged edges from a wide button in internet explorer? For example:

alt text

like image 546
brad Avatar asked Sep 29 '08 20:09

brad


3 Answers

You can also eliminate Windows XP's styling of buttons (and every other version of Windows) by setting the background-color and/or border-color on your buttons.

Try the following styles:

background-color: black;
color: white;
border-color: red green blue yellow;

You can of course make this much more pleasing to the eyes. But you get my point :)

Stack Overflow uses this approach.

like image 53
cllpse Avatar answered Oct 02 '22 18:10

cllpse


As a workaround, you can remove the blank spaces on each end of the button, which has the effect of decreasing the jagged edges. This is accomplished with the following css and a bit of jQuery:

input.button {
   padding: 0 .25em;
   width: 0; /* for IE only */
   overflow: visible;
}

input.button[class] { /* IE ignores [class] */
    width: auto;
}

$(function(){
    $('input[type=button]').addClass('button');
});

The jQuery is for adding the button class. A more in depth write up can be found here.

like image 21
brad Avatar answered Oct 02 '22 19:10

brad


Setting overflow: visible; on the button will cure the issue in IE 6 and 7.

(See http://jehiah.cz/archive/button-width-in-ie)

Exceptions

  • In IE 6, if display:block; is also applied to the button, the above fix won't work.

    Setting the button to display:inline; in IE 6 will make the fix work.

  • If you have a button like this within a table cell, then the table cell won't contract to the new, smaller width of the button.

    You can fix this in IE 6 by setting width: 0; on the button. However, in IE 7 this will make everything but the text of the button disappear.

    (See http://latrine.dgx.cz/the-stretched-buttons-problem-in-ie)

More info on styling buttons:

http://natbat.net/2009/Jun/10/styling-buttons-as-links/

like image 29
Paul D. Waite Avatar answered Oct 02 '22 18:10

Paul D. Waite