css单选/多选按钮样式改变

单选(radio)例子:

css:

input[type=radio]:checked + .rad_1, .rad_1.checked {
 background: #ccc;
 }
 .rad_1 {
 border: 1px solid #ccc;
 padding: 7px 16px;
 box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
 border-radius: 5px;
 }

HTML:

<input type="radio" class="radios" name="kind" id="status_on1"  value="1"  checked="checked"/>
<label for="status_on1" class="rad_1" data-id="1">radio1</label>
<input type="radio" class="radios" name="kind" id="status_on2" value="2"/>
<label for="status_on2" class="rad_1" data-id="2">radio2</label>
<input type="radio" class="radios" name="kind" id="status_on3"  value="3"/>
<label for="status_on3" class="rad_1" data-id="3">radio3</label>

ps:input的id要与label的for一致调整label的css

多选(checkbox)例子
例1:
css:

.check input{display: none;}
 input[type=checkbox]:checked + .rad_1, .rad_1.checked {background:url(__PUBLIC__/images/radio1.png) no-repeat right center;background-size:25px 25px;width: 25px;height: 25px;}
 .rad_1 {background:url(__PUBLIC__/images/radion2.png) no-repeat right center;background-size:25px 25px;width: 25px;height: 25px;}

HTML:

<input type="checkbox" class="checkboxs" name="years[]" id="status_ono{$i}" value="{$vo.id}" checked="checked"/>
<label for="status_ono{$i}" data-id="{$i}" class="rad_2">{$vo.batchnum|date='Y',###}</label>

例2:
css:

input[type=checkbox]:checked +i{color: #39bc56}
 .rad_2 .glyphicon-check{color: #aeb3b9}

html:

<label for="ch1" data-id="1" class="rad_2">
                <input type="checkbox" class="checkboxs" name="" id="ch1" value="1"/>
                <i class="glyphicon glyphicon-check"></i>
                <span style="color: red;">
                    选项一
                </span>
            </label>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值