纯CSS可在Chrome中使用。但并非所有浏览器。

有任何想法吗?

这是我的示例代码:

https://jsfiddle.net/kdtrtb03/5/

<label class="radioLabel">
    <input type='radio' value='false' name='test' />
    <span>No&nbsp;</span>
</label>
<label class="radioLabel">
    <input type='radio' value='true' name='test' />
    <span>Yes&nbsp;</span>
</label>



.radioLabel {
        padding-left: 10px;
}
.radioLabel span {
        padding-left: 17px;
        padding-top: 5px;
}

.radioLabel input[type=radio] {
        cursor:pointer !important;
}

.radioLabel input[type=radio]:after {
        content:' ';
        position:relative;
        display:inline-block;
        top:-2px;
        left:-2px;
        width:15px;
        height:15px;
        background-color:gray;
        border-radius:20px;
        border:gray solid 4px;
}

.radioLabel input[type=radio]:checked:after {
        background-color:red;
}

最佳答案

输入不能包含:after:before元素,应将css应用于范围:

.radioLabel span:before {
  content: ' ';
  position: relative;
  display: inline-block;
  top: -2px;
  left: -2px;
  width: 15px;
  height: 15px;
  background-color: gray;
  border-radius: 20px;
  border: gray solid 4px;
}

.radioLabel input[type="radio"]:checked + span:before {
  background-color: red;
}


JSFiddle Demo

09-12 14:55