首页 > 其他 > 详细

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

时间:2017-12-21 16:53:01      阅读:268      评论:0      收藏:0      [点我收藏+]
如果觉得设置样式太麻烦,或者页面上选中的样式太复杂,也可以用背景图去修改样式
<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>
 

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

原文:http://www.cnblogs.com/da-yao/p/8081168.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!