修改单选框的样式

1 篇文章 0 订阅

看了好多的资料,有的说radio样式不能修改因为那是默认的,有的说可以。最后还是通过和朋友谈论实现的。

单选框的圆的样式可以修改。其实就是给一个新的样式将原来的覆盖掉,而不是真正的修改了原来的默认样式。

下来上代码

css的

.inputt input[type=radio]+label, inputtt input[type=radio]+label{
                    line-height: 1;
                    position: relative;
                    display: -webkit-box;
                    display: -webkit-flex;
                    display: -ms-flexbox;
                    display: flex;
                    -webkit-box-align: center;
                    -webkit-align-items: center;
                    -ms-flex-align: center;
                    align-items: center;
                    margin-top: -20px;
                }
                .inputt input[type=radio]+label:before, .inputtt input[type=radio]+label:before{
                    line-height: 20px;
                    display: inline-block;
                    width: 13px;
                    height: 13px;
                    margin-right: 8px;
                    content: '';
                    color: #fff;
                    border: 1px solid #dce4e6;
                    background-color: #f3f6f8;
                    border-radius: 3px;
                }
//这块的checked是单选选定的 使用背景图实现
                .inputt input[type=radio]:checked+label:before, .inputtt input[type=radio]:checked+label:before{
                    content:' ';
                    background:rgba(255, 207, 0, 1) url(../../static/images/zheng.png)  no-repeat;
                    background-size:cover;
                }

HTML 的代码

 <div class="inputt">
      <input type="radio" name="picRadio" checked="checked" id="radioOne"/>
      <label for="radioOne">学生</label>
 </div>
 <div class="inputtt">
      <input type="radio" name="picRadio" id="radioTwo"/>
      <label for="radioTwo">非学生</label>
 </div>

切记HTML中 id="radio" 必须写不写的话不能点击,不要问我为什么,我也是实践之后知道的。 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值