自定义单选按钮

268 阅读1分钟
 <div class="right_model3_font">您的性别</div>
    <input type="radio" name="types" id="radio3" value="男" class="radio_types" checked><label for="radio3">男</label>
    <input type="radio" name="types" id="radio4" value="女" class="radio_types"><label for="radio4">女</label>




.radio_types {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    outline: none;
    width: 20px;
    height: 20px;
    margin-right: 4px;
    border: 1px solid #e1dad1;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 10px;
}

.radio_types:before {
    content: '';
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    border-radius: 4px;
}

.radio_types:checked:before {
    content: '';
    background: #ff5b5b;
    display: inline-block;
    vertical-align: middle;
}

.radio_types:checked+label {
    color: #ee4d4d;
}