css ๋์์ธ์ ํ๊ณ ์ํ๋๋ก ~,~
See the Pen Untitled by 123 (@123-the-scripter) on CodePen.
html ํตํฉ ์ฝ๋
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Toggle Button</title>
<style>
.nyang-toggle-container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 50px;
}
.nyang-toggle-button {
position: relative;
width: 50px;
height: 30px;
border-radius: 30px; /* ์ ๋์ด ๋ฅ๊ธ๊ฒ ์ฒ๋ฆฌ๋ ์ฌ๊ฐํ */
background: #ccc;
cursor: pointer;
transition: background 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* ์ธ๋ถ ๊ทธ๋ฆผ์ */
}
.nyang-toggle-heart {
position: absolute;
top: 50%;
left: 5px;
transform: translateY(-50%);
font-size: 22px;
color: #fff; /* ํ์์ ํํธ */
transition: left 0.3s ease;
}
.nyang-toggle-button.active {
background: #f385af;
}
.nyang-toggle-button.active .nyang-toggle-heart {
left: 25px; /* ์ค๋ฅธ์ชฝ์ผ๋ก ์ด๋ */
}
.nyang-more-box {
width: 200px;
height: 0;
background-color: #fff;
color: #333;
text-align: center;
padding: 0;
margin-top: 10px;
transition: height 0.3s ease, padding 0.3s ease;
border-radius: 8px;
overflow: hidden;
}
.nyang-more-box.active {
height: 60px;
padding: 10px;
}
</style>
</head>
<body>
<div class="nyang-toggle-container">
<div class="nyang-toggle-button" id="nyangToggleButton">
<span class="nyang-toggle-heart">♥</span>
</div>
<div class="nyang-more-box" id="nyangMoreBox">
์๋
ํ์ธ์^^
</div>
</div>
<script>
const toggleButton = document.getElementById('nyangToggleButton');
const moreBox = document.getElementById('nyangMoreBox');
toggleButton.addEventListener('click', () => {
toggleButton.classList.toggle('active');
moreBox.classList.toggle('active');
});
</script>
</body>
</html>