如果我使用以下 CSS 创建一个 input
input {
border: none;
font-family: arial, sans-serif;
font-size: 16px;
line-height: 16px;
padding: 0;
}
我预计 input
的高度为 16px,但 Chrome 开发者工具显示的高度为 18px。
在 Firefox 中,高度为 16px。
是什么导致 Chrome 中额外的 2px?
fiddle :https://jsfiddle.net/fh7upk0n/
我知道如果我想要一个固定的高度我必须使用高度,但我想知道 2px 是从哪里来的。
最佳答案
你应该使用height而不是line-height
height- the vertical measurement of the container
line-height- the distance from the top of the first line of text to the top of the second
关于html - Chrome 中的 CSS 输入高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42888544/