【发布时间】:2021-11-30 11:59:47
【问题描述】:
试图弄清楚为什么带有class="input-group form-fieldset_select" 的 div 不在网格单元内,而是低于它。
.form-fieldset {
width: 290px;
height: auto;
border: none;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 20px 56px;
row-gap: 8px;
}
.form-fieldset > legend {
padding: 0;
margin: 0;
}
.input-group {
grid-row: 2/3;
display: flex;
}
.form-fieldset_select {
justify-content: center;
}
.select-button-label {
color: black;
font-size: 16px;
font-weight: 400;
text-align: center;
width: 128px;
height: 56px;
border: 1px solid gold;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.select-button-label > input {
position: absolute;
z-index: -1;
top: 0;
left: 0;
opacity: 0;
}
<fieldset class="form-fieldset">
<legend>Legend</legend>
<div class="input-group form-fieldset_select">
<label class="select-button-label">
Button1
<input type="text" />
</label>
<label class="select-button-label">
Button2
<input type="text" />
</label>
</div>
</fieldset>
【问题讨论】: