如何更改 iOS 和安卓瀏覽器上的 input[type="radio"] 元素的默認樣式?

Safari 上的默認樣式是這樣的,css

背景顏色可使用background-color改變,但中間那個點始終沒法去掉。web

我查了一些jQuery插件,如iCheck.js,可是那說明寫得我都看不明白,根本不知道如何使用。app

還有-webkit-appearance:none;屬性會直接將input[type="radio"]元素隱藏。spa

應該如何更改?個人目標只是一個選中時是純色的圓形,未選中時是帶邊框的透明圓形。.net

 

還可用css僞類寫插件

<h3>CSS3 Custom radio</h3>
<div class="radio"> 
    <input type="radio" value="1" name="sex" id="radio1" checked>
    <label for="radio1"></label>
    <br>
    <input type="radio" value="0" name="sex" id="radio2">
    <label for="radio2"></label>
</div>
label {
    cursor: pointer;
    display: inline-block;
    font-size: 13px;
    margin-right: 15px;
    padding-left: 25px;
    position: relative;
}
input[type="radio"] {
    display: none;
}
label:before {
    background-color: #a06b63;
    bottom: 1px;
    box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.3) inset, 0 1px 0 0 rgba(255, 255, 255, 0.8);
    content: "";
    display: inline-block;
    height: 16px;
    left: 0;
    margin-right: 10px;
    position: absolute;
    width: 16px;
}
.radio label:before {
    border-radius: 8px;
}
input[type="radio"]:checked + label:before {
    color: #f3f3f3;
    content: "•";
    font-size: 30px;
    line-height: 18px;
    text-align: center;
}

地址:https://jsfiddle.net/chic/q2t1z17a/code

相關文章
相關標籤/搜索