Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button rendered differently in Firefox vs Webkit

I have a couple of buttons inside a div with a specific width, and I am facing a problem where the buttons are being rendered differently in firefox vs chrome and safari.

In firefox, the buttons are bigger and are messing up my layout.

<div id="sort_by">
    <button id="sort_by_price" class="sortButton" value="1">Price</button>
    <button id="sort_by_bedrooms" class="sortButton" value="1">Bedrooms</button>
    <button id="compareButton" class="sortButton">Compare</button>
</div>

CSS:

button {
display:inline;
float:left;
background-color:orange;
border:1px solid orange;
border-radius:5px;
-moz-border-radius:5px;

font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
font-size:14px;
text-decoration:none;
font-weight:bold;
color:#FFFFFF;
cursor:pointer;
padding:4px 10px 3px 7px;

}

#sort_by {
width:265px;
height:35px;
border-bottom-style:solid;
border-bottom-width:2px;
border-color:#c9c9c9;
padding-top:3px;
padding-bottom:3px;
padding-left:5px;
}

Rendered in firefox:

enter image description here

Rendered in Chrome:

enter image description here

It can be seen that the buttons in firefox are bigger. How can I fix this? Thanks.

like image 213
AlexBrand Avatar asked May 09 '11 16:05

AlexBrand


1 Answers

Firefox adds an extra margin/padding to button elements that cannot be changed by standard CSS, you can however add the following to make it behave

button::-moz-focus-inner { 
    border: 0;
    padding: 0;
}
like image 81
JaredMcAteer Avatar answered Nov 06 '22 19:11

JaredMcAteer