我不明白为什么选择元素的宽度比输入元素的宽度短,我将它们都设置为100%,但似乎输入出于某种原因覆盖网格边界。输入元素宽度短于选择元素宽度
HTML:
<div class="gridView">
<input type="text" placeholder="Name" />
<input type="text" placeholder="Last Name" />
<select></select>
<input type="text" placeholder="Birth Date" />
<select> </select>
<select> </select>
<input type="text" placeholder="Passport Number" />
<span>
<input placeholder="Passport Expiry Date"/>
<span class="dateFormat">YYYY-MM-DD</span>
</span>
</div>
CSS:
input {
width: 100%;
padding: 6px;
height: 25px;
}
select {
height: 41px;
width:100%;
}
.gridView {
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 25px;
grid-row-gap: 10px;
font-family: sans-serif;
margin: auto;
width: 50%;
}
.dateFormat {
color: red;
font-size: small;
display: block;
margin-left: 15px;
margin-bottom: 5px;
font-weight: bold;
}
的jsfiddle
https://jsfiddle.net/AlexLavriv/oxmq71sn/1/
你的小提琴与这里的源不一样;它不会设置例如“选择”宽度。 –
添加:* {margin:0; padding:0; box-sizing:border-box} – VXp