본문 바로가기
개발/UI

체크박스 디자인-1 (checkbox Design-1 with CSS)

by kxxxgs 2023. 5. 9.
728x90

체크박스 디자인 1

 

기본 체크박스로 활용할 수 있다.

 

 

 

✔️ HTML

<div class="cbxBox">
    <input checked="" type="checkbox" id="cb1">
    <label for="cb1" class="cbx"></label>
</div>

 

✔️ CSS

.cbxBox {
    position: relative;
}
.cbxBox .cbx {
    position: relative;
    display: block;
    width: 25px;
    height: 25px;
    border: 1px solid #a1a1a1;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.cbxBox .cbx:after {
    content: '';
    position: absolute;
    top: 2px;
    left: 10px;
    width: 5px;
    height: 14px;
    opacity: 0;
    transform: rotate(45deg) scale(0);
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transition: all 0.3s ease;
}
.cbxBox input[type=checkbox] {
    display: none !important;
}
.cbxBox input[type=checkbox]:checked ~ .cbx {
    border-color: transparent;
    background: #392ca7;
    animation: anima 0.6s ease;
}
.cbxBox input[type=checkbox]:checked ~ .cbx:after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}
@keyframes anima {
    from {
        transform: scale(1, 1);
    }
    25% {
        transform: scale(0.95, 0.95);
    }
    50% {
        transform: scale(1.15, 1.15);
    }
    75% {
        transform: scale(0.95, 0.95);
    }
    to {
        transform: scale(1, 1);
    }
}

 

✔️ GitHub

https://github.com/rudtn082/UI/tree/main/checkbox1

반응형

댓글