使用背景图修改radio、checkbox样式

本文转载于:猿2048网站使用背景图修改radio、checkbox样式

如果觉得使用CSS伪类设置样式太麻烦,或者页面上选中的样式太复杂CSS无法模拟,也可以用背景图去替换样式
<div class="">
<label><input type="radio" name="1"><i class="spot"></i>123456</label>
<label><input type="radio" name="1"><i class="spot"></i>123456</label>
</div>
<style>
label{
display:inline-block;
width:200px;
height:50px;
line-height:.8rem;
text-align:left;
position: relative;
}
label input{
width: 15px;
height: 15px;
vertical-align: bottom;
margin-right:.1rem;
opacity: 0;
}
.spot{
display:inline-block;
width:17px;
height:17px;
background:url("image/radio.png") no-repeat; /*默认的样式图片*/
background-size:16px;
position: absolute;
top:.2rem;
left:0;
z-index:5;
}
input:checked + .spot{
background:url("image/checked.png") no-repeat; /*选中后的样式图片*/
background-size:16px;
}
</style>
 

转载于:https://my.oschina.net/u/4191619/blog/3100058

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值