Creating a one-page website with an event countdown timer and interactive features involves writing HTML, CSS, and JavaScript code. Below is a step-by-step guide to creating this website, along with the code and instructions on how to use it.
html<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Birthday Countdown Timer</title> <style> body { font-family: Arial, sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } .container { text-align: center; } #timer { font-size: 2em; margin-bottom: 20px; } .pinwall, .poll, .upload { margin-bottom: 20px; } .pinwall textarea, .poll select, .upload input { width: 100%; padding: 10px; margin-top: 10px; border-radius: 5px; border: 1px solid #ccc; } .pinwall button, .poll button, .upload button { padding: 10px 20px; border: none; border-radius: 5px; background-color: #ff6347; color: white; cursor: pointer; } .pinwall button:hover, .poll button:hover, .upload button:hover { background-color: #ff4500; } .messages, .results, .gallery { margin-top: 20px; } .gallery img { max-width: 100px; margin: 5px; } </style> </head> <body> <div class="container"> <h1>🎉 Birthday Countdown Timer 🎉</h1> <div id="timer">Time left until the big day!</div> <div class="pinwall"> <h2>📌 Pinwall 📌</h2> <textarea placeholder="Leave a message for [birthday child]"></textarea><br> <button onclick="addMessage()">Add Message</button> <div class="messages" id="messages"></div> </div> <div class="poll"> <h2>🗳 Poll 🗳</h2> <select id="pollSelect"> <option value="funny">Funny</option> <option value="kind">Kind</option> <option value="smart">Smart</option> </select><br> <button onclick="vote()">Vote</button> <div class="results" id="results"></div> </div> <div class="upload"> <h2>📸 Upload a Picture 📸</h2> <input type="file" id="fileInput" accept="image/*"><br> <button onclick="uploadPicture()">Upload</button> <div class="gallery" id="gallery"></div> </div> </div> <script> // Countdown Timer function updateTimer() { const targetDate = new Date('2030-01-01T00:00:00Z').getTime(); const now = new Date().getTime(); const distance = targetDate - now; const days = Math.floor(distance / (1000 * 60 * 60 * 24)); const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((distance % (1000 * 60)) / 1000); document.getElementById('timer').innerHTML = `${days}d ${hours}h ${minutes}m ${seconds}s`; if (distance < 0) { clearInterval(timerInterval); document.getElementById('timer').innerHTML = "It's the big day!"; } } const timerInterval = setInterval(updateTimer, 1000); // Pinwall function addMessage() { const message = document.querySelector('.pinwall textarea').value; if (message.trim() !== '') { const messagesDiv = document.getElementById('messages'); const messageElem = document.createElement('div'); messageElem.innerText = message; messagesDiv.appendChild(messageElem); document.querySelector('.pinwall textarea').value = ''; } } // Poll const pollResults = {}; function vote() { const vote = document.getElementById('pollSelect').value; pollResults[vote] = (pollResults[vote] || 0) + 1; updatePollResults(); } function updatePollResults() { const resultsDiv = document.getElementById('results'); resultsDiv.innerHTML = ''; for (const [key, value] of Object.entries(pollResults)) { const resultElem = document.createElement('div'); resultElem.innerText = `${key}: ${value}`; resultsDiv.appendChild(resultElem); } } // Picture Upload function uploadPicture() { const fileInput = document.getElementById('fileInput'); const file = fileInput.files[0]; if (file) { const reader = new FileReader(); reader.onload = function(e) { const imgElem = document.createElement('img'); imgElem.src = e.target.result; document.getElementById('gallery').appendChild(imgElem); } reader.readAsDataURL(file); } } </script> </body> </html>
Save the File:
.html extension, for example, birthday_countdown.html.Open the File:
This code provides a fully functional and interactive birthday countdown website. You can customize the text, styles, and functionality further to better suit your needs.
When I mention saving the file with a .html extension, I'm referring to creating a new file on your computer where you can paste the HTML code. Here are the steps to do this:
Copy the Code:
Ctrl+C (Windows) or Cmd+C (Mac) to copy the code.Open a Text Editor:
Create a New File:
Ctrl+N (Windows) or Cmd+N (Mac).Paste the Code:
Ctrl+V (Windows) or Cmd+V (Mac).Save the File:
.html extension. To do this:
Ctrl+S (Windows) or Cmd+S (Mac)..html, for example, birthday_countdown.html..html extension.Open the File in a Web Browser:
By following these steps, you'll create an HTML file that you can open in a web browser to view and interact with your birthday countdown website.