請看看這個codepen:CodePen。我有以下的html:CSS:設置div的背景顏色填充
<fieldset class="rangeset">
<div class="range-container">
<label for="question_three_radio_01">
<input id="question_three_radio_01" name="question_three" type="radio" value="0" /><span></span>
</label>
<label for="question_three_radio_02">
<input id="question_three_radio_02" name="question_three" type="radio" value="1" /><span></span>
</label>
<label for="question_three_radio_03">
<input id="question_three_radio_03" name="question_three" type="radio" value="2" /><span></span>
</label>
<label for="question_three_radio_04">
<input id="question_three_radio_04" name="question_three" type="radio" value="3" /><span></span>
</label>
<label for="question_three_radio_05">
<input id="question_three_radio_05" name="question_three" type="radio" value="4" /><span></span>
</label>
<label for="question_three_radio_06">
<input id="question_three_radio_06" name="question_three" type="radio" value="5" /><span></span>
</label>
</div>
</fieldset>
而這個CSS:
[type="radio"] {
border: 0;
clip: rect(0 0 0 0);
height: 1px; margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.radio-label {
display: block;
cursor: pointer;
line-height: 0;
}
[type="radio"] + span:before {
content: '';
display: inline-block;
width: 20px;
height: 20px;
vertical-align: -5px;
border: 2px solid #fff;
box-shadow: 0 0 0 2px #000;
margin-right: 20px;
transition: 0.5s ease all;
}
[type="radio"]:checked + span:before {
background: #A4B162;
box-shadow: 0 0 0 4px #48530D;
}
fieldset {
border: 2px solid #48530D;
padding-top: 27px;
padding-right: 20px;
padding-bottom: 0px;
padding-left: 20px;
}
.rangeset {
padding-top: 27px;
padding-right: 0px;
padding-bottom: 20px;
}
.range-container {
display: flex;
justify-content: space-between;
}
我現在想要做的是創造一個背景顏色是一樣厚和寬爲所有單選按鈕一起。我試圖設置div的背景顏色,但結果是這樣的:CodePen 2
這裏設置的背景顏色已經和單選按鈕一樣厚(如此完美),但是如果你看一下非常合適的單選按鈕,看到背景顏色比所有的單選按鈕都寬。我想要在最後一個單選按鈕結束時停止背景顏色。
你有什麼想法嗎?
無法看到任何背景的條紋在第二演示。你能提供更多關於你需要填充的細節嗎? – Harry
真的嗎?您在我發佈的第二個codepen中的單選按鈕的背景中看不到綠色條紋?如果我打開鏈接,我可以看到它。條紋太厚。我需要它更薄,只需要和單選按鈕一樣寬。你可以看到右邊的單選按鈕,條紋繼續進一步。測試了我在Chrome,Firefox和Opera上發佈的CodePen 2。我可以在任何地方看到它 – Mulgard
我看不到任何條紋。我看到的只是一個黑色邊框,有一些填充(白色)區域和一個綠色固體內部填充。 – Harry