Firefox和Chrome中的输入高度差异

Jit*_*yas 29 css cross-browser

为什么Chrome中的高度比输入的Firefox大

见这里的例子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;
}
Run Code Online (Sandbox Code Playgroud)

Joo*_*nas 59

问题基本上就是line-height.

Chrome看起来line-height很像它看到的height,Firefox却没有.

添加高度到输入应解决问题,但你应该小心你line-heightheight匹配.

例如:height: 20px; line-height: 20px;.

http://jsfiddle.net/e2agj/1/ - 最后一个示例输入是正确的.