通过CSS3伪类,美化Radio按钮样式

本文介绍如何使用CSS3来自定义HTML中的Radio按钮样式,并通过伪元素实现选中状态的视觉效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CSS3样式:

/* RADIO */
.button-holder {
 width: 100%;
}
.regular-radio {
 display: none;
}
.regular-radio + label {
 -webkit-appearance: none;
 background-color: #fafafa;
 border: 1px solid #cacece;
 box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05);
 padding: 9px;
 border-radius: 50px;
 display: inline-block;
 position: relative;
}
.regular-radio:checked + label:after {
 content: ' ';
 width: 12px;
 height: 12px;
 border-radius: 50px;
 position: absolute;
 top: 3px;
 background: #99a1a7;
 box-shadow: inset 0px 0px 10px rgba(0,0,0,0.3);
 text-shadow: 0px;
 left: 3px;
 font-size: 32px;
}

 

 

代码:

<div class="button-holder">
   <input type="radio" id="radio-1-1" name="radio-1-set" class="regular-radio" checked /><label for="radio-1-1"></label><br />
   <input type="radio" id="radio-1-2" name="radio-1-set" class="regular-radio" /><label for="radio-1-2"></label><br />
   <input type="radio" id="radio-1-3" name="radio-1-set" class="regular-radio" /><label for="radio-1-3"></label><br />
   <input type="radio" id="radio-1-4" name="radio-1-set" class="regular-radio" /><label for="radio-1-4"></label><br />
  </div>

转载于:https://www.cnblogs.com/anhuidu/p/4485570.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值