.switch {
    position: relative;
    display: inline-block;

}

.switch input {
    display: none;
}

.switch input:checked+label {
    background: skyblue;
}

.switch label:active:after {
    width: 30px;
}

.switch input:checked+label:after {
    left: calc(100% - 2px);
    transform: translateX(-100%);
}

.switch label {
    cursor: pointer;
    width: 50px;
    height: 20px;
    background: grey;
    display: block;
    border-radius: 20px;
    position: relative;
}

.switch label:after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 16px;
    transition: 0.3s;
}

.switch-txt::before,
.switch-txt::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: block;
    color: #fff;
    font-weight: bold;
    box-sizing: border-box;

}

.switch-txt::before {
    content: attr(data-txt-on);
    color: #fff;
    left: 5px;
}

.switch-txt::after {
    content: attr(data-txt-off);
    color: #ccc;
    right: 5px;
}

.switch input:not(:checked)+label .switch-txt::before {
    display: none;
}

.switch input:checked+label .switch-txt::after {
    display: none;
}