云端漂移 2019-06-27
纯CSS实现radio和checkbox实现效果
<div class="reset-radio">
<input checked type="radio" id="age1" name="age">
<span class="real-target"></span>
</div>.reset-radio {
display: inline-block;
position: relative;
width: 16px;
height: 16px;
}
.reset-radio .real-target {
z-index: 1;
width: 100%;
height: 100%;
position: absolute;
display: inline-block;
background: #ffffff;
border: 1px solid #dadde0;
border-radius: 100%;
top: 0;
left: 0;
bottom: 0;
}
.reset-radio input[type=radio] {
cursor: pointer;
z-index: 2;
width: 16px;
height: 16px;
opacity: 0;
position: absolute;
left: 0;
top: 0;
margin: 0;
right: 0;
bottom: 0;
}
.reset-radio input:checked+span {
border-color: #48b4ec;
}
.reset-radio input:checked+span::before {
content: '';
position: absolute;
background: #48b4ec;
width: 6px;
height: 6px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 100%;
}