프런트엔드-CSS

CSS 스타일링

강사: 최퍼블리셔 · 작성자: 이종춘 · 작성일: 2026-04-27 18:25:12 · 조회수: 7

스타일시트 트랜지션 문제1번 다른방법 설명
목록으로
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>

*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

.btn_wrap{
width: 150px;
height: 60px;
background-color: gray;
margin: 100px auto;
border-radius: 50px;
position: relative;
transition: 0.5s;
display: block;
cursor: pointer;
}

.btn{
width: 50px;
height: 50px;
border-radius: 50%;
background-color: white;
position: absolute;
top: 5px;
left: 5px;
transition: 0.5s;
}

#check{
display: none;
}

#check:checked ~ .btn_wrap{
background-color: green;
}

#check:checked ~ .btn_wrap .btn{
left: 95px;
}

</style>
</head>
<body>

<input type="checkbox" id="check">

<label for="check" class="btn_wrap">
<div class="btn"></div>
</label>

</body>
</html>
#스타일시트 트랜지션 문제1번 다른방법

첨부 파일

0개
첨부된 파일이 없습니다.

댓글 / 답글

0개
댓글을 작성하려면 로그인하세요.
아직 댓글이 없습니다.