纯css重写单选radio多选CheckBox样式,选中取消选中自定义。

18 篇文章 2 订阅

好了先看看实现后的效果吧,样式可以自定义修改的,代码很容易看懂,新手都可以用;
在这里插入图片描述
上面是选中状态,下面是未选中状态,支持反选多选取消选中,看下面代码:

<!-- HTML部分 -->
<div  class="checkbox">
  <input type="checkbox"  id="checkbox1"/>
  <label for="checkbox1"><span class="icons"></span></label>
</div>
  //css 部分
  .checkbox {
    height: 20px;
    width: 20px;
    margin: 0 20px;
    border-radius: 50%;
    cursor: pointer;
    .icons{
      display: inline-block;
      width: 6px;
      height: 6px;
      border-radius: 3px;
      background: #f0f0f0;
      z-index: 990;
      position: absolute;
      top: 7px;
      left: 7px;
    }
    input{
      display: none;
    }
    label{
      width: 100%;
      height: 30px;
      display: inline-block;
      line-height: 30px;
      position: relative;
      text-align: center;
    }
    label:active{
      background: #ffffff;
    }
    label:after{
      content: "";
      width: 18px;
      height: 18px;
      border: 1px solid #777;
      border-radius: 18px;
      display: inline-block;
      position: absolute;
      top: 0px;
      left: 0px;
    }
    input:checked+label:after{
      border: 1px solid $theme;
      background-color: $theme;
    }
  }

好了,希望帮你解决问题,喜欢的小伙伴点个关注吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端攻城狮路飞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值