html结构
<ul class="radioes">
<li>
<input type="radio" name="radio" id="radio1" checked>
<label for="radio1"></label>
</li>
<li>
<input type="radio" name="radio" id="radio2">
<label for="radio2"></label>
</li>
<li>
<input type="radio" name="radio" id="radio3">
<label for="radio3"></label>
</li>
<li>
<input type="radio" name="radio" id="radio4">
<label for="radio4"></label>
</li>
</ul>
css样式
ul,li{
list-style: none;
margin: 0;
padding: 0;
}
.radioes{
margin: 100px auto;
}
.radioes li{
float: left;
margin: 0 10px;
}
.radioes input{
display: none;
}
.radioes label{
display: block;
width: 100px;
height: 50px;
background-color: #ccc;
border-radius: 50px;
position: relative;
transition: all ease .5s;
}
.radioes label:after{
content: '';
width: 48px;
height: 48px;
background-color: #fff;
border-radius: 50%;
position: absolute;
left: 2px;
top: 1px;
transition: all ease .5s;
}
.radioes input:checked + label:after{
left: 50px;
}
.radioes input:checked + label{
background-color: #4ace55;
}
欢迎访问我的博客,同步发布
感谢阅读,如有错误欢迎指正。
网友评论