如何自定義radio的樣式,更改選中的顏色?


1.html代碼
<div class="rdo">
        <input name="sex" id="male" type="radio">
        <label for="male">男</label>
</div> 
<div class="rdo">
        <input name="sex" id="female" type="radio">
        <label for="female">女</label>
</div> 
 
2.樣式
input[type="radio"] + label::before {
    content: " ";
    display: inline-block;
    vertical-align: middle;
    width: .853333rem;
    height: .853333rem;
    border-radius: 50%;
    border: .064rem solid #fd8869;
    margin-right: .213333rem;
    box-sizing: border-box;
}
input[type="radio"]:checked + label::before {
    background-color: #fd8869;
    background-clip: content-box;
    padding: .149333rem;
    box-sizing: border-box;
}
input[type="radio"] {
    position: absolute;
    clip: rect(0, 0, 0, 0);
}
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM