仍然在调查表格项目上工作,并且按钮对齐有问题。
如下面的示例所示,第一个单选按钮应该与左侧的文本一致,这是一个问题:
然而,我已经玩过display
和其他CSS元素,甚至尝试margin
和padding
,其中没有一个似乎使我的按钮正确排列。我的按钮如下所示:
我下面显示的相关代码产生了错误的结果:
HTML:
<label for="recommend">*How likely is that you would recommend freeCodeCamp to a friend?</label>
<div class="button-group">
<div class="label-button"> <label for="recommend"><input type="radio" id="recommend" class="input-box" name="recommend" value="definitely">Definitely</label>
</div>
<div class="label-button">
<input type="radio" name="recommend" class="input-box" name="recommend" value="maybe">Maybe</label>
</div>
<div class="label-button">
<input type="radio" name="recommend" class="input-box" name="recommend" value="not-sure">Not sure</label>
</div>
CSS:
#survey-form {
width: 70%;
max-width: 640px;
margin: 0 auto;
}
.row {
display: flex;
align-items: center;
justify-content: flex-end;
}
.row > * {
flex-basis: 50%;
box-sizing: border-box;
}
.row label {
text-align: right;
}
.input-field {
margin-left: 1em;
padding: 0.5em;
margin-bottom: 0.5em;
height: 40px;
width: 280px;
border: 1px solid gray;
border-radius: 2px;
}
.input-select {
margin-left: 1em;
padding: 0.5em;
margin-bottom: 0.5em;
width: 100px;
height: 40px;
border: 1px solid gray;
border-radius: 2px;
}
.button-group {
padding-left: 0.5em;
}
form {
width: 70%;
max-width: 640px;
margin: 0 auto;
}
.label-button {
margin-bottom: 0.5em;
}
Codepen链接也在这里:https://codepen.io/jerryd2304/pen/qvERZL
adding align-item to flex-start
.row.align-item-start {
align-items: flex-start;
}
<div class="row align-item-start">
[here is the codepen link for the same][1]
[https://codepen.io/dasg1/pen/WmQgqy][1]