Firefox css button style has unwanted padding / edges

Yesterday, I asked https://stackoverflow.com/a/212960/ for a problem with stock / addition in Firefox. I got an answer and accepted it. Today I realized that my problem has not been resolved. So, I am posting a new question.

Jsfiddle - problem

Jsfiddle - problem solved

CSS

.btn { text-align: center; color: #333; font-weight: 700; font-size: 11px; font-family: tahoma, verdana, arial, helvetica; background: -webkit-linear-gradient(#fefefe, #e7e7e7); background: -o-linear-gradient(#fefefe, #e7e7e7); background: -moz-linear-gradient(#fefefe, #e7e7e7); background: linear-gradient(#fefefe, #e7e7e7); height: 24px; width: auto; overflow: visible; border: 1px solid #c4c4c4; padding: 0 10px; line-height: 22px; border-radius: 3px; } .btn:hover { color: #111; border: 1px solid #555; } 

Html

 <input type="submit" value="Submit" class="btn" /> 

The problem is that this button does not look normal in Firefox:

enter image description here

I made the solution proposed by Ant:

 .btn::-moz-focus-inner { padding:0; border:0; } 

Later I discovered that it only works if there is a text field <input type="text"...> in front of the submit button. If the text box is missing, for some strange reason, the problem still exists. I partially deleted the entire css file to see that some rules in the css file are causing the problem. It did not help. I created a new file with the following contents:

 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>test</title> <style type="text/css"> .btn { text-align: center; color: #333; font-weight: 700; font-size: 11px; font-family: tahoma, verdana, arial, helvetica; background: -webkit-linear-gradient(#fefefe, #e7e7e7); background: -o-linear-gradient(#fefefe, #e7e7e7); background: -moz-linear-gradient(#fefefe, #e7e7e7); background: linear-gradient(#fefefe, #e7e7e7); height: 24px; width: auto; overflow: visible; border: 1px solid #c4c4c4; padding: 0 10px; line-height: 22px; border-radius: 3px; } .btn:hover { color: #111; border: 1px solid #555; } .btn::-moz-focus-inner { padding:0; border:0; } </style> </head> <body> <input type="submit" value="Submit" class="btn" /> </body></html> 

The same problem - it looks different in Firefox. Only in Jsfiddle is everything okay.

So I'm looking for some kind of solution. A button looks ugly in Firefox if the top margin is larger than the bottom margin.

+5
source share
1 answer

Tested in CH46 +, FF DE44 + and IE11 + (below the order of the image buttons) on W7, remove the rule ::moz and change the .btn line-height: 1; and you will get the following result:

enter image description here

As you now see, IE is one pixel. But IE also uses a remarkable different font smoothing procedure. I have seen this before on various sites. I would not spend too much time fixing pixel differences if I were you, since even browser developers cannot crack it ...

+2
source

Source: https://habr.com/ru/post/1235955/


All Articles