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

來源:互聯網
上載者:User

標籤:

Safari 上的預設樣式是這樣的,

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

我查了一些jQuery外掛程式,如iCheck.js,但是那說明寫得我都看不明白,根本不知道如何使用。

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

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

 

還可用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/

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.