返回代码库

国风倒计时页面设计

4.0
zh网页设计国风设计倒计时页面纪念日页面

提示语

创建一个包含侧边栏的国风倒计时或纪念日页面

生成结果

import React, { useState, useEffect } from 'react';

const App = () => {
  const targetDate = new Date('2025-01-01T00:00:00');
  const [timeLeft, setTimeLeft] = useState(calculateTimeLeft());

  function calculateTimeLeft() {
    const difference = +targetDate - +new Date();
    let timeLeft = {};

    if (difference > 0) {
      timeLeft = {
        days: Math.floor(difference / (1000 * 60 * 60 * 24)),
        hours: Math.floor((difference / (1000 * 60 * 60)) % 24),
        minutes: Math.floor((difference / 1000 / 60) % 60),
        seconds: Math.floor((difference / 1000) % 60)
      };
    }

    return timeLeft;
  }

  useEffect(() => {
    const timer = setTimeout(() => {
      setTimeLeft(calculateTimeLeft());
    }, 1000);

    return () => clearTimeout(timer);
  });

  const formatTime = (time) => time < 10 ? `0${time}` : time;

  return (
    <div className="flex h-screen bg-gradient-to-r from-green-400 to-blue-500 text-white">
      <div className="w-1/5 bg-opacity-50 bg-black p-6">
        <h1 className="text-3xl font-bold mb-6">Countdown</h1>
        <nav>
          <ul>
            <li className="mb-4"><a href="#" className="hover:text-gray-400">Home</a></li>
            <li className="mb-4"><a href="#" className="hover:text-gray-400">About</a></li>
            <li className="mb-4"><a href="#" className="hover:text-gray-400">Contact</a></li>
          </ul>
        </nav>
      </div>
      <div className="w-4/5 flex justify-center items-center">
        <div className="text-center">
          <h1 className="text-6xl font-bold mb-12">Countdown to New Year 2025</h1>
          <div className="flex justify-center space-x-8">
            <div className="bg-black bg-opacity-50 p-6 rounded-lg">
              <div className="text-6xl font-bold">{formatTime(timeLeft.days)}</div>
              <div className="text-2xl">Days</div>
            </div>
            <div className="bg-black bg-opacity-50 p-6 rounded-lg">
              <div className="text-6xl font-bold">{formatTime(timeLeft.hours)}</div>
              <div className="text-2xl">Hours</div>
            </div>
            <div className="bg-black bg-opacity-50 p-6 rounded-lg">
              <div className="text-6xl font-bold">{formatTime(timeLeft.minutes)}</div>
              <div className="text-2xl">Minutes</div>
            </div>
            <div className="bg-black bg-opacity-50 p-6 rounded-lg">
              <div className="text-6xl font-bold">{formatTime(timeLeft.seconds)}</div>
              <div className="text-2xl">Seconds</div>
            </div>
          </div>
        </div>
      </div>
      <footer className="absolute bottom-0 w-full text-center p-4 bg-black bg-opacity-50">
        © 2025 Countdown App. All rights reserved.
      </footer>
    </div>
  );
};

export default App;

更多推荐

查看全部

交互式元素周期表

网页设计zh
4.0

Create a website for me using a single HTML code so I can place it on my Google Blogger blog. The name of the website is " Interactive Periodic Table " Create this website for me based on the following instructions, descriptions, and recommendations: using this website, user can Explores the elements that make up our world. The periodic table is arranged based on atomic number, electron configuration, and recurring chemical properties. the user Clicks on any element to discover detailed information. The user Downloads easily the result on his device. The site must be responsive and provide users with the ability to enter information and download results easily, quickly, and conveniently. Please add a reset button to restore the site to its original state. When writing the website code, please optimize the website's appearance to make it as professional as possible, advanced, responsive, and compatible with various devices. please display a RESET BUTTON. Be creative in choosing shapes, colors, and fonts, all of which must be professional, artistic, and attractive so that the website can meet the competition. please use only english language.

HTML代码响应式设计元素周期表2025/6/20

专业作品集网站

网页设计en
4.0

create a detailed,uniique beautiful professional portfolio sample website

作品集网站设计专业展示2025/4/4

旅游网站落地页设计

网页设计en
4.0

create a landing page for a tourism website of a destination

旅游网站设计目的地2025/4/4

获奖照片弹窗设计

网页设计zh
4.0

生成一个获奖照片弹窗,要求动态展示

弹窗设计动态展示获奖照片2025/4/2

打造终极书店网站

网页设计zh
4.0

Create an a bookstore website that shows books in different categories with short descriptions and a picture of the book and a summery button and get button that goes to WhatsApp account with number +967772492426 make the design best design ever with using Tailwind, do your best and add any features you thing it will be perfect for the idea

书店网站Tailwind设计WhatsApp集成2025/4/1

数字时钟与搜索框

网页设计zh
4.0

数字时钟和搜索框

数字时钟搜索框网页设计2025/3/31