input height differences in Firefox and Chrome
Asked Answered
A

7

30

Why height in Chrome is bigger than Firefox of input

See example here http://jsfiddle.net/jitendravyas/89Msh/1/

select, input, textarea, button {
    font: 99% sans-serif;
}

input, select {
    vertical-align: middle;
}

body, select, input, textarea {
    color: #444444;
}

button, input, select, textarea {
    margin: 0;
}


input, textarea {
    font-family: inherit;

    line-height: 1.5;
}


input {
    border: 0 none;
    font-size: 32px;
    line-height: 1.1;
    margin-right: 29px;
    padding: 3px 3px 0;
    width: 206px;
    border-radius: 7px;
}
Arlberg answered 29/8, 2011 at 11:38 Comment(1)
try reseting the css property of input, i mean reset margin, padding to 0. try this, i am not sureShrink
V
61

The problem is essentially line-height.

Chrome sees line-height much like it sees height and Firefox doesn't.

Adding height to the input should solve the problem, though you should be careful that your line-height and height match.

For example: height: 20px; line-height: 20px;.

http://jsfiddle.net/e2agj/1/ - Last example input is the correct one.

Velure answered 29/8, 2011 at 12:15 Comment(1)
Thanks for explanation. I added height along with line-height. it solved the problemArlberg
P
1

I usually use padding instead of height to push the total height of the input. Doing so, I do not have to fight around with the different interpretations of Chrome and Firefox.

Poachy answered 9/9, 2013 at 17:2 Comment(0)
J
1

Simply try overflow:hidden on input

Jailbird answered 22/1, 2016 at 10:27 Comment(0)
E
0

I think it has to do with the way you styled the font for the input.

select, input, textarea, button {
    font: 99% sans-serif;
}

Each browser has its own rendering for sans-serif, as that is really not a font.

Therefore, without a specific font set, you could expect some inconsistencies.

Enrica answered 29/8, 2011 at 11:44 Comment(1)
I think it's not because size is same here jsfiddle.net/jitendravyas/4wfvD/1Arlberg
P
0

This should work in Chrome & Firefox on select elements:

height: 20px;
padding: 0;
Penstemon answered 19/11, 2013 at 0:0 Comment(0)
Q
0

I had the same problem and had to combine line-height AND padding to make things work.

Quamash answered 1/12, 2014 at 23:14 Comment(0)
F
0

I had gone throught same input line-height problem across Firefox , Chrome & Opera browsers. So I combined line-height , height and font-size for the appropriate look.

input {                   
        line-height: 45px;
        height: 45px;
        font-size: 45px;
      }
Flightless answered 28/7, 2015 at 12:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.