在同一容器中,使用display: block的输入文本会如预期那样拉伸以填满可用空间,但如果我将类型更改为“date”,它会变得更短。为什么呢?
HTML:
<div class="panel">
<div class="input-group">
<label for="text1">text1</label>
<input id="text1" type="text"/>
</div>
<div class="input-group">
<label for="date">date</label>
<input id="date" type="date" />
</div>
<div class="input-group">
<label for="text2">text2</label>
<input id="text2" type="text" />
</div>
</div>
CSS(层叠样式表):
.panel {
display: flex;
flex-wrap: wrap;
}
.input-group {
flex-grow: 1;
text-align: left;
}
label, input {
display: block;
}
结果:text1和text2的大小相同,但日期较短。
input
和input[type="date"]
都没有任何默认的宽度(或高度)值。实际上,Chrome的“计算”样式甚至会链接回样式的源,但宽度却没有任何链接。 - Quangdao Nguyen