"Coming Soon" Page with Dark Background and Countdown Timer

Answered using ChatGPT 4o by ChatGPT4o

Question:

HTML, CSS, Dar Background. One Single Page, Coming Soon, Count Down set for July, 28, 2024

Answer:

Sure! Below is a simple HTML and CSS code for a "Coming Soon" page with a dark background and a countdown timer set for July 28, 2024.

HTML (index.html)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Coming Soon</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <h1>Coming Soon</h1>
        <p id="countdown"></p>
    </div>

    <script>
        // Set the date we're counting down to
        var countDownDate = new Date("July 28, 2024 00:00:00").getTime();

        // Update the count down every 1 second
        var x = setInterval(function() {

            // Get today's date and time
            var now = new Date().getTime();

            // Find the distance between now and the count down date
            var distance = countDownDate - now;

            // Time calculations for days, hours, minutes and seconds
            var days = Math.floor(distance / (1000 * 60 * 60 * 24));
            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
            var seconds = Math.floor((distance % (1000 * 60)) / 1000);

            // Display the result in the element with id="countdown"
            document.getElementById("countdown").innerHTML = days + "d " + hours + "h "
            + minutes + "m " + seconds + "s ";

            // If the count down is over, write some text 
            if (distance < 0) {
                clearInterval(x);
                document.getElementById("countdown").innerHTML = "EXPIRED";
            }
        }, 1000);
    </script>
</body>
</html>

CSS (styles.css)

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #121212;
    color: #ffffff;
    font-family: Arial, sans-serif;
}

.container {
    text-align: center;
}

h1 {
    font-size: 3em;
    margin-bottom: 20px;
}

#countdown {
    font-size: 2em;
}

Explanation:

  1. HTML Structure:

    • The HTML file includes a div with a class of container that contains an h1 element for the "Coming Soon" text and a p element with an id of countdown for the countdown timer.
    • A script is included at the bottom of the body to handle the countdown logic.
  2. CSS Styling:

    • The CSS file styles the body to have a dark background (#121212), centers the content both vertically and horizontally, and sets the text color to white.
    • The container class centers the text.
    • The h1 and #countdown elements are styled to have larger font sizes for better visibility.
  3. JavaScript Countdown:

    • The JavaScript code calculates the time remaining until July 28, 2024, and updates the countdown every second.
    • If the countdown reaches zero, it displays "EXPIRED".

You can save the HTML and CSS code in their respective files (index.html and styles.css) and open the index.html file in a web browser to see the "Coming Soon" page with