カスタムラジオボタンを一列に整列しようとしていますが、問題が発生しています。テキストが実際に長いが、ラジオボタンが重なっている場合。私はそれらのいずれかに修正幅を割り当てたいとは思わない。また、エラー処理のためにラジオボタンの境界線を変更したい場合は、.radio .custom
スタイリングが必要です。私はhtml構造を変更するために開いていますが、custom
スパンの内側にTextが必要です。私は必要に応じて内側のスパンを取り除くことができます。ラジオボタンの整列問題
display:flex;
label
に、それは私に右のお互いの上に、各オプションを与えてしまった:
私が使って試してみました。
* {
box-sizing: border-box;
}
input[type="radio"] {
display: none;
cursor: pointer;
}
label {
cursor: pointer;
min-width: 50px;
display: inline-block;
position: relative;
}
.radio span.custom > span {
margin-left: 24px;
margin-right: 10px;
}
.radio .custom {
content: '';
height: 20px;
left: 0;
top: 0;
width: 20px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 100%;
position: absolute;
}
.radio input:checked + .custom:before {
background-color: blue;
border-radius: 100%;
border: 3px solid #fff;
content: "";
display: block;
height: 12px;
position: absolute;
top: 0;
width: 12px;
z-index: 1;
left: 0;
}
.radio input + .custom:after {
border-radius: 100%;
}
.checkbox input:checked .custom {
background-color: blue;
border-color: blue;
}
<label class="radio">
<input type="radio">
<span class="custom"><span>Onasasasase</span></span>
</label>
<label class="radio">
<input type="radio">
<span class="custom"><span>Two</span></span>
</label>