下面是HTML代码
<label>
<input type="checkbox" class="hidden_input" />
<span class="checkbox"></span>
我是标签
</label>
css代码
.hidden_input {
opacity: 0;
position: absolute;
z-index: -1;
}
input[type=checkbox]+span {
/* 自定义样式 */
display: inline-block;
height: 1em;
width: 1em;
border-radius: 50%;
background-color: gray;
}
/* 动态变化时的样式 */
input[type=checkbox]:checked+span {
background-color: red;
}