先瞧瞧效果

css控制复选框为按钮样式

css样式
/*按钮初始化设置*/
input[type="checkbox"].switch_1{
    font-size: 30px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 2em;
    height: 0.85em;
    background: #ddd;
    border-radius: 1em;
    position: relative;
    cursor: pointer;
    outline: none;
    -webkit-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;
}
/*按钮的背景颜色*/
input[type="checkbox"].switch_1:checked{
    background: #0ebeff;
}
/*圆形的设置*/
input[type="checkbox"].switch_1:after{
    position: absolute;
    content: "";
    width: 0.85em;
    height: 0.85em;
    border-radius: 50%;
    background: #fff;
    -webkit-box-shadow: 0 0 .25em rgba(0,0,0,.3);
    box-shadow: 0 0 .25em rgba(0,0,0,.3);
    -webkit-transform: scale(.7);
    transform: scale(.7);
    left: 0;
    -webkit-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;
}
/*按钮的改变事件*/
input[type="checkbox"].switch_1:checked:after{
    left: calc(100% - 0.95em);
}
html复选框
<input type="checkbox" class="switch_1"  >

相关文章:

  • 2021-09-20
  • 2021-06-14
  • 2021-11-22
  • 2021-09-20
  • 2021-12-19
  • 2021-12-10
  • 2021-11-30
  • 2021-11-30
猜你喜欢
  • 2021-12-10
  • 2022-01-08
  • 2021-12-10
  • 2021-11-12
  • 2021-12-28
  • 2021-11-30
  • 2021-12-06
相关资源
相似解决方案