ildar-k
6/2/2019 - 5:15 PM

CSS switch

input[type="checkbox"] {
    /* pos: relative on oluline, et seesmist ringi saaks paigutada absolute'ga */
    position: relative;
    width: 8rem;
    height: 4rem;
    /* checkbox nähtamatuks */
    -moz-appearance: none;
    -webkit-appearance: none;
    -o-appearance: none;
    appearance: none;
    background: #c6c6c6;
    /* selekteerimise piirjoon minema */
    outline: none;
    border-radius: 2rem;
    transition: .5s;
    /* sisemine vari */
    box-shadow: inset 0 0 5px rgba(0, 0, 0, .2);
}

input:checked[type="checkbox"] {
    background: #03a9f4;
}

input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 4rem;
    height: 4rem;
    top: 0;
    left: 0;
    border-radius: 50%;
    background: #ffffff;
    transform: scale(0.8);
    transition: .5s;
}

input:checked[type="checkbox"]::before {
    left: 4rem;
}