I'm trying to style a text input with a value, text input with a placeholder, and a span, identically in Chrome. Specifically, I would like to control the line-height independently of the font size.
However, there seems to be some sort of minimum line-height (or something causing a similar affect) on the input value, that seems to push the text down somehow that prevents the identical styling.
Example HTML:
<div>
<input type="text" value="Text">
<input type="text" placeholder="Text">
<span>Text</span>
</div>
CSS:
div {
line-height: 50px;
font-family: Arial;
}
input,
span {
font-size: 50px;
line-height: 50px;
height: 50px;
width: 100px;
padding: 0;
min-height: 0;
display: inline-block;
font-family: inherit;
border: 2px solid red;
overflow: hidden;
vertical-align: top;
}
And the results can be seen at
http://plnkr.co/edit/oHbhKDSPTha8ShWVOC7N?p=preview
and in the following screen shot from Chrome 44.0.2403.155 (64-bit) on Linux:
Strangely, the placeholder seems to be styled with the desired line-height, while the text value of the input is positioned differently. I'm not concerned with the colour of the placeholder at this point.
How can I style all 3 elements so the text is in the same position, where I'm using a custom line-height?
I understand I can just set the line-height to normal
or 1.2
, or reduce the font size, to make the elements appear identically, but they would not have the visual appearance I'm looking for.
question from:
https://stackoverflow.com/questions/33185205/text-input-on-chrome-line-height-seems-to-have-a-minimum 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…