【发布时间】:2016-05-05 05:00:36
【问题描述】:
我一直在玩单字体(因为每个字符都与下一个字符一样宽)以匹配输入字段的长度。我的问题是5rem is equal to 10 characters? 怎么会在 chrome 和 firefox 中进入我的输入字段?你会期望 10 个字符的宽度为 10rem:
input[type="text"] {
border: 0;
outline: 0;
background: transparent;
border-bottom: 2px solid black;
font-family: 'monospace';
overflow: hidden;
width: 5rem;
}
<body id="body">
<form onSubmit="return false">
<input type="text" placeholder="your name" maxlength="10" required />
<input type="submit" />
</form>
</body>
【问题讨论】:
-
作为旁注,
rem单位是相对于您的 sn-p 未指定的“基本字体大小”(html标签的)。浏览器默认为 16 像素。