CSS checked 상태에 따라 label 꾸미기

sookyeong·2022년 3월 30일
0

checked 상태에 따라 label 꾸미기

HTML

<input type="radio" id="yes" value="yes" checked>
<label for="yes"></label>

CSS

#yes+label {
    display: inline-block;
    width: 68px;
    height: 31px;
    background: url("https://user-images.githubusercontent.com/98504939/154197039-22c2a53c-f13a-4124-b92a-5b888da8bea8.svg") no-repeat 0 0px / contain;
}

#yes:checked+label {
    background: url("https://user-images.githubusercontent.com/98504939/154194073-0af2ed1f-d718-4b33-aa30-0c978356ff2d.svg") no-repeat 0 0px / contain;
}

결과

profile
actions speak louder than words

0개의 댓글