作者:白猫警员123 | 来源:互联网 | 2020-08-05 23:30
本文给大家介绍手写CSS+js实现radio单选按钮,有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。
有的时候我们需要用长得漂亮一点的单选按钮,那么,就要抛弃原有的自己来写,下面就是我实现的
你丑你先
你才丑你先
你更丑你先
.radio{
display: flex;
align-items: center;
width: 100px;
cursor: pointer;
}
.yuan{/*大圈*/
display: block;
width: 10px;
height: 10px;
border-radius: 50%;
background: #ececec;/*这里写自己喜欢的颜色*/
display: flex;
align-items: center;
margin-right: 5px;
}
.radio>span.rdactive{
background: #EF6121;/*这里写自己喜欢的颜色*/
}
.yuan span{/*小圈*/
display: block;
width: 4px;
height: 4px;
border-radius: 50%;
background: white;/*这里写自己喜欢的颜色*/
margin: 0 auto;
}
$(".radio").children('.yuan').on('click',function(){
$('.rdactive').removeClass('rdactive');
$(this).addClass("rdactive").siblings().removeClass("rdactive");
})
效果图:
div/css图文教程
以上就是手写CSS+js实现radio单选按钮的详细内容,更多请关注 第一PHP社区 其它相关文章!