CSS3特效-自定义radio

自定义checkbox样式

  • 效果图:
    在这里插入图片描述
  • 代码
// css
.radio {
	display: none;
}
.radio+label {
	display: inline-block;
	position: relative;
}

.radio+label {
	padding-left: 20px;
	box-sizing: border-box;
}
.radio+label:before{
	content: "";
	width: 14px;
	height: 14px;
	display: inline-block;
	position: absolute;
	transform: translateY(-50%);
	top: 50%;
	right: 0px;
}
.radio+label:before {
	width: 18px;
	height: 18px;
	left: 0px;
	background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><circle cx="7" cy="9" r="7" transform="translate(1 -1)" fill="#FFF" stroke="#D9DBD9"></circle></svg>');
}

.radio[type=radio]:checked+label:before {
	background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><g transform="translate(2 2)" fill="none"><circle stroke="#C0E6FF" stroke-width="2" fill="#09F" cx="7" cy="7" r="8"></circle><circle fill="#FFF" cx="7" cy="7" r="2"></circle></g></svg>');
}
//使用
<h2>radio</h2>
   <div>
       <input id="label1" class="radio" type="radio" name="sex" checked>
       <label for="label1"></label>
       <input id="label2" class="radio" type="radio" name="sex">
       <label for="label2"></label>
   </div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值