switch 按钮

  /* 必须为类型为[checkbox]的[input]添加 switch 类名才能实现以下效果 */
  input[type=checkbox].switch{
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
    width: 2.8rem;
    height: 1.5rem;
    border: 1px solid #cccccc;
    background-color: #cccccc;
    border-radius: 0.7rem;
}
input[type=checkbox].switch::after{
    content: "";
    display: inline-block;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 0 2px #999;
    transition: left 0.1s;
    position: absolute;
    top: 0px;
    left: 0;
}
/* 
默认不被选中
当input[type=checkbox]被选中时,元素显示以下样式 
*/
input[type=checkbox].switch:checked{
    background-color: #32b258;
}
/* 
当input[type=checkbox]被选中时,伪元素显示以下样式--位置发生变化 
*/
input[type=checkbox].switch:checked::after{
    position: absolute;
    top: 0px;
    left: 50%;
}

/* 状态 */
input[type=checkbox]:checked.switch.switch-info{
    background-color: #31b0d5;
}
input[type=checkbox]:checked.switch.switch-danger{
    background-color: #ff1022;
}
input[type=checkbox]:checked.switch.switch-primary{
    background-color: #409eff;
}
input[type=checkbox].switch.switch-primary{
    background-color: red;
}
input[type=checkbox]:checked.switch.switch-warm{
    background-color: #e6a23c;
}

例子程序:

    <input type="checkbox" class="switch switch-info">
    <input type="checkbox" class="switch switch-primary">
    <input type="checkbox" class="switch switch-danger">
    <input type="checkbox" class="switch switch-warm">
    <input type="checkbox" class="switch">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值