【发布时间】:2017-10-28 16:46:27
【问题描述】:
我不明白为什么select元素的宽度比输入元素的宽度短,我都设置为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;
}
【问题讨论】:
-
你的fiddle和这里的源码不一样;例如,它没有设置
select宽度。 -
添加:* {margin:0;padding:0;box-sizing:border-box}