单选框radio-复选框checkbox去掉默认样式添加新样式及点击事件

 使用 -webkit-appearance: none;border-radius: 0;  outline: 0; 更改单选框radio-复选框checkbox去掉默认样式,然后自己定义自己想要的单选框radio-复选框checkbox新样式,同时给他们添加点击新的点击效果。

      最后样式如上所述...

<title>消除表单自定义样式自己定义样式</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        p {
            position: relative;
            margin-left: 40px;
        }

        /* 消除原有样式样子 */
        input {
            /* 将样式去掉了... */
            /* iphone及ipad下输入框button,input,textarea默认内阴影 */
            -webkit-appearance: none;
        }

        input {
            border-radius: 0;
            outline: 0;
        }

        /* 自定义复选框 */
        input[type="checkbox"] {
            width: 16px;
            height: 16px;
            border: 1px solid #ccc;
        }

        .gou {
            display: none;
            position: absolute;
            left: 3px;
            top: 5px;
            width: 10px;
            height: 5px;
            border-width: 0px 0px 2px 2px;
            border-style: solid;
            border-color: #333;
            transform: rotate(-45deg);
        }

        input[type="checkbox"]:checked~.gou {
            display: block;
        }

        /* 自定义单选框 */
        input[type="radio"] {
            width: 16px;
            height: 16px;
            border: 1px solid #ccc;
            border-radius: 50%;
        }

        .quan {
            display: none;
            position: absolute;
            left: 0;
            top: 0;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            border: 2px solid #8b76f9;
            box-shadow: 0px 0px 3px 0px #8b76f9 inset;
        }

        input[type="radio"]:checked+.quan {
            display: block;
        }
    </style>
</head>

<body>
    <div class="contanier">
        <p>
            <input type="checkbox" name="" id="">
            <!-- 自定义勾选 -->
            <em class="gou"></em>
        </p>
        <p>
            <!-- 自定义圈圈样式 -->
            <input type="radio" name="sex" id="">
            <em class="quan"></em>
        </p>
        <p>
            <!-- 自定义圈圈样式 -->
            <input type="radio" name="sex" id="">
            <em class="quan"></em>
        </p>
    </div>
</body>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值