diff --git a/js/heartAnimation.js b/js/heartAnimation.js index 2eb9e47..9f50966 100644 --- a/js/heartAnimation.js +++ b/js/heartAnimation.js @@ -1,27 +1,31 @@ const heartElement = document.getElementById('heart'); -const body = document.body; +const gridElement = document.getElementById('likelion_grid'); function createHeart() { - const heart = document.createElement('div'); + const heart = document.createElement('div'); //비어있는 div에 이미지 형태의 하트 생성 heart.innerHTML = ` `; - heart.classList.add('heart'); - heart.style.left = Math.random() * 100 + 'vw'; - heart.style.animationDuration = Math.random() * 2 + 3 + 's'; - body.appendChild(heart); + heart.classList.add('heart'); //하트 여러개 생성 + + const gridOffsetTop = gridElement.offsetTop; //그리드 시작부근에서 떨어지기 + heart.style.top = `${gridOffsetTop}px`; + heart.style.left = Math.random() * 100 + 'vw'; // 랜덤 위치 + heart.style.animationDuration = Math.random() * 2 + 3 + 's'; //속도=랜덤 + + document.body.appendChild(heart); setTimeout(() => { - heart.remove(); + heart.remove(); //시간이 지나면 하트 제거 }, 3000); } // 하트 영역 클릭 이벤트 heartElement.addEventListener('click', () => { for (let i = 0; i < 10; i++) { - setTimeout(createHeart, i * 200); + setTimeout(createHeart, i * 200); //200 간격으로 새로운 하트 생성 } }); diff --git a/styles/header.css/hd.css b/styles/header.css/hd.css index 0cb14c7..ed1aad1 100644 --- a/styles/header.css/hd.css +++ b/styles/header.css/hd.css @@ -99,7 +99,7 @@ color: #F9C756; text-decoration: none; } -@media screen and (max-width: 749px) { +@media screen and (max-width: 449px) { #header_navigation { display: none; } @@ -108,7 +108,7 @@ color: #F9C756; } } -@media screen and (min-width: 750px) { +@media screen and (min-width: 450px) { #header_navigation { display: inline-block; } @@ -123,19 +123,20 @@ color: #F9C756; cursor: pointer; } .heart { - position: absolute; z-index: 1500; + position: absolute; width: 30px; height: 30px; - animation: float 3s linear infinite; + animation: fall 3s linear infinite; } -@keyframes float { +@keyframes fall { 0% { - transform: translateY(100vh) scale(0.5); + transform: translateY(0) scale(0.5); opacity: 1; } 100% { - transform: translateY(-10vh) scale(1.5); + transform: translateY(100vh) scale(1.5); opacity: 0; } -} \ No newline at end of file +} +