<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>원형 파티클</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f5f5f5;
overflow: hidden;
}
.container-wrapper {
position: relative;
width: 300px;
height: 300px;
}
/* 방사형 애니메이션 */
.ripple-effect {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
background: conic-gradient(
red, orange, yellow, green, cyan, blue, violet, red
);
animation: rotate 4s linear infinite;
filter: blur(10px);
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/* 컨테이너 */
.container {
position: relative;
text-align: center;
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #e0f7fa;
border: 2px solid #333;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.container h1 {
font-size: 1.5rem;
margin: 0;
}
.container .days {
font-size: 2.5rem;
font-weight: bold;
color: #d32f2f;
margin: 10px 0;
}
.container p {
font-size: 1rem;
margin: 5px 0;
}
@keyframes particleMove {
0% {
transform: translate(0, 0) scale(1);
opacity: 1;
}
100% {
transform: translate(var(--x), var(--y)) scale(0.5);
opacity: 0;
}
}
/* 날짜 입력창 */
.input-wrapper {
margin-bottom: 20px;
text-align: center;
}
.input-wrapper input {
padding: 8px;
font-size: 1rem;
border: 1px solid #ccc;
border-radius: 4px;
}
.input-wrapper button {
padding: 8px 16px;
font-size: 1rem;
margin-left: 10px;
background-color: #007aff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.input-wrapper button:hover {
background-color: #005ecb;
}
</style>
</head>
<body>
<div class="input-wrapper">
<input type="date" id="startDateInput" />
<button onclick="applyStartDate()">날짜 적용</button>
</div>
<div class="container-wrapper">
<div class="ripple-effect"></div>
<div class="container">
<h1>책 읽기</h1>
<div class="days" id="days">0</div>
<p id="message">일 연속으로 책 읽기를 달성했군요.</p>
<p>축하합니다!</p>
</div>
</div>
<script>
let startDate = new Date(); // 기본 시작 날짜를 오늘로 설정
let particleAngle = 0; // 초기 파티클 각도
// 날짜 계산 및 표시
function updateDays() {
const currentDate = new Date();
const diffTime = currentDate - startDate;
const diffDays = Math.max(Math.floor(diffTime / (1000 * 60 * 60 * 24)), 0); // 최소 0일
document.getElementById("days").textContent = diffDays;
document.getElementById("message").textContent = `${diffDays}일 연속으로 책 읽기를 달성했군요.`;
}
// 날짜 입력 적용
function applyStartDate() {
const inputDate = document.getElementById("startDateInput").value;
if (inputDate) {
startDate = new Date(inputDate);
updateDays();
}
}
updateDays(); // 초기 날짜 표시
</script>
</body>
</html>