维科纳蒂 »
×
改变方向
在 Codepen 上打开
更改主题,深色/浅色
<!DOCTYPE html> <html> <head><meta http-equiv="content-security-policy" content="script-src 'none'"> <title>W3.CSS Шаблон</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../styles/w3.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway"> <style> body,h1 {font-family: "Raleway", sans-serif} body, html {height: 100%} .bgimg { background-image: url('../images/forestbridge.jpg'); min-height: 100%; background-position: center; background-size: cover; } </style> </head> <body> <div class="bgimg w3-display-container w3-animate-opacity w3-text-white"> <div class="w3-display-middle"> <h1 class="w3-jumbo w3-animate-top">WEEKEND</h1> <hr class="w3-border-grey" style="margin:auto;width:40%"> <p class="w3-large w3-center" id="weekend_countdown">35 днів залишилось</p> </div> <div class="w3-display-bottomleft w3-padding-large"> Powered by <a href="https://22ae.com/w3css/index.html" target="_blank">w3.css</a> </div> </div> <script> // Function to calculate the countdown function countdown() { // Get the current date var currentDate = new Date(); // Check if it's Saturday if (currentDate.getDay() === 6) { var countdownElement = document.getElementById("weekend_countdown"); countdownElement.innerHTML = "The Weekend has landed"; return; // Exit the function early if it's Saturday } // Find the next Saturday var daysToSaturday = (6 - currentDate.getDay() + 7) % 7; // Number of days until the next Saturday var nextSaturday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + daysToSaturday); // Calculate the remaining time var timeRemaining = nextSaturday.getTime() - currentDate.getTime(); var daysRemaining = Math.floor(timeRemaining / (1000 * 60 * 60 * 24)); var hoursRemaining = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); // Display the countdown on the web page var countdownElement = document.getElementById("weekend_countdown"); countdownElement.innerHTML = daysRemaining + " днів та " + hoursRemaining + " годин"; } // Call the countdown function when the page loads window.onload = function() { countdown(); }; </script> </body> </html>