zoukankan      html  css  js  c++  java
  • 如何更改 iOS 和安卓浏览器上的 input[type="radio"] 元素的默认样式?

    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;
         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/

  • 相关阅读:
    IntelliJ IDEA更新maven依赖包
    PHP运行出现Notice
    JetBrains CLion
    SQL中GROUP BY的使用
    LCA 总结
    HAProxy:第三方包及编译安装
    nginx之升级openssl及自定义nginx版本
    nginx之http反向代理多台服务器
    nginx之rewrite相关功能
    nginx之rewrite及防盗链
  • 原文地址:https://www.cnblogs.com/nifengs/p/5206225.html
Copyright © 2011-2022 走看看