码迷,mamicode.com
首页 > 移动开发 > 详细

如何更改 iOS 和安卓浏览器上的 input[type="radio"] 元素的默认样式?

时间:2016-02-22 10:19:40      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

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"] 元素的默认样式?

标签:

原文地址:http://www.cnblogs.com/nifengs/p/5206225.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!