Firefox add's 2px padding in a submit button
I was having a problem like this. I then found this CSS
thingy that solved the problem:
input::-moz-focus-inner { border:0; padding:0 }
This solution was given in a comment in this blog post:
Bulletproof CSS input button heights
As the post says: this happens because Firefox (User Agent) own CSS
style uses !important
and anything one tries to do to override the CSS
property won't get applied.
Input (submit) element occupies extra space in Firefox
Remove button padding in Firefox by using input::-moz-focus-inner
in your CSS:
input::-moz-focus-inner /*Remove button padding in FF*/
{
border: 0;
padding: 0;
}
EDITED: Updated Demo Link with above code.
SEE DEMO in firefox
Remove extra button spacing/padding in Firefox
Add this:
button::-moz-focus-inner {
padding: 0;
border: 0
}
http://jsfiddle.net/thirtydot/Z2BMK/1/
Including the border
rule above is necessary for buttons to look the same in both browsers, but also it removes the dotted outline when the button is active
in Firefox. Lots of developers get rid of this dotted outline, optionally replacing it with something more visually friendly.
Text input and submit input elements have different height in firefox
All browsers have differences between default behaviours and styles, but firefox is more flexible with S.O. and form elements are controlled by default by the operating system.
The solution is remove padding or use height with EM meassures.
Remove padding:
https://jsfiddle.net/04camn42/2/
.class { padding: 0 }
Using EM height:
https://jsfiddle.net/04camn42/3/
.class {
height: 1.5em
}
IF you use EM you don't worry about responsiveness and user choices.
Why the extraneous horizontal padding inside button (Firefox only)?
Add this styles to fix it:
button::-moz-focus-inner {
padding: 0;
border: 0;
}
Code snippet (JSFiddle):
* { outline: none;}
button { background: firebrick; width: 200px; height: 40px;
margin: 0px; padding: 0px; border: none;}
button > div { background: lightskyblue; margin: 0px; padding: 0px; border: none;}
button::-moz-focus-inner { padding: 0; border: 0;}
<div style="padding: 60px;"> <button> <div>label</div> </button></div>
input type=submit text vertical alignment in Firefox
I found this post because I had resolved this problem a few months ago and when I ran into it again today, I couldn't remember what I'd done. Nice. After poring over my css I finally located the "fix". I can't take credit because I found it on the web somewhere, but hopefully it will be as useful to you as it has been for me:
input::-moz-focus-inner /*Remove button padding in FF*/
{
border: 0;
padding: 0;
}
I hope this helps.
Related Topics
Bootstrap Carousel Caption Top Alignment
Options to Solve Browser Compatibility Issues
Wp_Enqueue_Style and Rel Other Than Stylesheet
Can a Child Div Have a Higher Opacity Than Parent with CSS
Is The CSS3 Transform Translate Percentage Values Relative to Its Width And/Or Height
How to Set Super Thin "Font-Weight" (Less Than 100) in CSS
What to Use Instead of Contains() in CSS3
How to Give Class to a Host Element in Angular 2 with @Hostbinding
What Is .Htc File How It Works in Internet Explorer
CSS: Opacity Only Background, Not The Text Inside
iPhone Viewport Height Too Large in Landscape Mode
Position Fixed on Chrome Mobile Causing Issues When Scrolling
Bootstrap 4.0 Invalid-Feedback Doesn't Show
Sass Importing Without Compiling
CSS3 Transform Matrix to Full Transform Conversion
Setting The Scrollbar Color in Safari for Lion (Os X 10.7)
Applying Borders to a Single Table Cell When Using Border-Collapse