【发布时间】:2016-11-17 23:32:32
【问题描述】:
我在这里有一个 jsfiddle - https://jsfiddle.net/5qmnptuk/4/
我正在尝试创建一个自定义单选按钮。
我隐藏了单选按钮,然后在标签上使用 :after 创建了新单选按钮。
我正在尝试使用 :checked 来设置点击的样式,但它不起作用
谁能明白为什么这不起作用。
.form-group{
margin-top: 30px;
}
label{
cursor: pointer;
display: inline-block;
position: relative;
padding-right: 25px;
margin-right: 15px;
}
label:after{
bottom: -1px;
border: 1px solid #aaa;
border-radius: 25px;
content: "";
display: inline-block;
height: 25px;
margin-right: 25px;
position: absolute;
right: -31px;
width: 25px;
}
input[type=radio]{
display: none;
}
input[type=radio]:checked + label{
content: \2022;
color: red;
font-size: 30px;
text-align: center;
line-height: 18px;
}
【问题讨论】: