0
基本上它是一個從1到10的答案調查。當有人點擊一個數字我想我的標籤背景改變顏色。我使用了單選按鈕,因爲他們只能選擇1個答案。(隱藏)單選按鈕的樣式標籤
<label class="lfirst">
<input type="radio" name="answer1" value="1">
1
</label>
<label>
<input type="radio" name="answer1" value="2">
2
</label>
<style>
input[type="radio"]{
display: none;
}
.answers label {
display: inline-block;
font-weight: bold;
margin: 0 3px 0 0;
padding: 4px 12px;
cursor: pointer;
background: orange;
}
.answers label + input[type="radio"]:checked{
background: red;
}
</style>
我不知道你想達到什麼目的?你想給背景顏色隱藏的選中字段?這是不可能的,因爲你隱藏它......除此之外,CSS中沒有父選擇器。 – Siyah
在CSS中沒有父選擇器:[Parent Selector](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – Manu
單選按鈕的意義是什麼,如果你將要把它藏起來? – httpgio