See this code example: http://jsfiddle.net/Z2BMK/
Chrome/IE8 look like this
Firefox looks like this
My CSS is
button {
padding:0;
background:#080;
color:white;
border:solid 2px;
border-color: #0c0 #030 #030 #0c0;
margin:0;
}
How can I change the code sample to make the button the same in both browsers? I do not want to use JavaScript based hyperlinks because they do not work with space bar on keyboard and it has to have an href
URL which is not a clean way to handle things.
My solution, since Firefox 13
button::-moz-focus-inner { margin: -1px; padding: 0; border-width: 1px; }
margin: -1px
? Is it somehow connected toborder: 2px
? – Mellisamellisentborder-width
of the-moz-focus-inner
was1px
by default, so the writingborder-width
into the code is redundant, but it makes it more clear what is going on. It is possible it may help in future-proofing as well. To answer your question, theborder-width
in Firefox was the cause of the difference, and addingmargin: -1px
is the solution which is more compatible than my previous solution. – Wurstermargin: -1px
. This is overcomplicated. It breaks if: 1)A bug in rendering engine appears(that happens), 2)Borders get different color, 3)You zoom in. To demonstrate potential problems with your solution, I've prepared a fiddle: jsfiddle.net/Z2BMK/455. Please zoom in and notice a red border appearing. – Mellisamellisentline-height
of the button, if it contains nothing but an image. – Underfoot