.wrapper {
display: flex;
flex-direction: column;
}
.group {
display: flex;
width: 300px;
justify-content: space-between;
margin-bottom: 10px;
}
.small {
width: 60px;
}

<div class="wrapper">
<div class="group">
<label>From</label>
<input>
<input class="small">
</div>
<div class="group">
<label>To</label>
<input>
<input class="small">
</div>
</div>
&#13;
如何对齐它以使它看起来像这样:
目前,第一个标签比第二个标签长,并且没有正确对齐。我怎样才能解决这个问题?感谢
答案 0 :(得分:2)
将固定宽度设置为标签:
.wrapper {
display: flex;
flex-direction: column;
}
.group {
display: flex;
width: 300px;
justify-content: space-between;
margin-bottom: 10px;
}
.small {
width: 60px;
}
label{
width: 60px;
}
<div class="wrapper">
<div class="group">
<label>From</label>
<input>
<input class="small">
</div>
<div class="group">
<label>To</label>
<input>
<input class="small">
</div>
</div>
答案 1 :(得分:1)
将固定宽度设置为标签:
.wrapper {
display: flex;
flex-direction: column;
}
.group {
display: flex;
width: 300px;
justify-content: space-between;
margin-bottom: 10px;
}
.small {
width: 60px;
}
label{
width: 60px;
}
答案 2 :(得分:0)
我想这将足够而不是那个
.small {
width: 60px;
}
<table>
<tr>
<td><label>From</label></td>
<td> <input> <input class="small"></td>
<tr>
<td> <label>To</label></td>
<td> <input> <input class="small"></td>
</tr>
</table>