找回密码
 立即注册
搜索
查看: 780|回复: 0

时间样式带文案的html代码

[复制链接]
8888
灌水成绩
11841
18
2032187
主题
帖子
积分

等级头衔

ID : 1

管理员

积分成就 威望 : 999999
贡献 : 9999
下载币 : 10331
在线时间 : 768 小时
注册时间 : 2025-4-1
最后登录 : 2025-9-3

发表于 2025-8-10 13:10:55 | 显示全部楼层 |阅读模式 IP:广东东莞

  padding: 20px;时间位置直接调


  1. <div class="greeting-container">
  2.     <div class="clock-face">
  3.         <div class="clock-time" id="clock-time"></div>
  4.     </div>
  5.     <div class="greeting-text">
  6.         <div class="greeting" id="greeting"></div>
  7.         <div class="tip" id="tip"></div>
  8.     </div>
  9. </div>
  10. <style>
  11.     .greeting-container {
  12.         width: 100%;
  13.         height: 150px;
  14.         background-color: #f5f5f5;
  15.         border-radius: 10px;
  16.         box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  17.         display: flex;
  18.         align-items: center;
  19.         justify-content: space-between;
  20.         padding: 20px;
  21.         font-family: Arial, sans-serif;
  22.     }
  23.     .clock-face {
  24.         width: 100px;
  25.         height: 100px;
  26.         background-color: #fff;
  27.         border-radius: 50%;
  28.         display: flex;
  29.         align-items: center;
  30.         justify-content: center;
  31.         box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  32.     }
  33.     .clock-time {
  34.         font-size: 24px;
  35.         font-weight: bold;
  36.         color: #333;
  37.     }
  38.     .greeting-text {
  39.         flex: 1;
  40.         margin-left: 20px;
  41.     }
  42.     .greeting {
  43.         font-size: 20px;
  44.         color: #007bff;
  45.         font-weight: bold;
  46.         margin-bottom: 10px;
  47.     }
  48.     .tip {
  49.         font-size: 16px;
  50.         color: #666;
  51.         line-height: 1.5;
  52.     }
  53. </style>
  54. <script>
  55.     function updateClock() {
  56.         const now = new Date();
  57.         const hours = now.getHours().toString().padStart(2, '0');
  58.         const minutes = now.getMinutes().toString().padStart(2, '0');
  59.         const seconds = now.getSeconds().toString().padStart(2, '0');
  60.         document.getElementById('clock-time').textContent = `${hours}:${minutes}:${seconds}`;
  61.     }

  62.     function updateGreeting() {
  63.         fetch('https://api.ahfi.cn/api/getGreetingMessage?type=json')
  64.             .then(response => response.json())
  65.             .then(data => {
  66.                 document.getElementById('greeting').textContent = data.data.greeting;
  67.                 document.getElementById('tip').textContent = data.data.tip;
  68.             })
  69.             .catch(error => console.error('Error fetching the greeting message:', error));
  70.     }

  71.     document.addEventListener('DOMContentLoaded', function() {
  72.         updateClock();
  73.         updateGreeting();
  74.         setInterval(updateClock, 1000);
  75.         setInterval(updateGreeting, 60000);
  76.     });
  77. </script>
复制代码


公告
帖子地址打造全网最多免费游戏网站
今日来客 列表模式
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站已运行

QQ|Archiver|手机版|小黑屋|蔡州手游 |网站地图

GMT+8, 2025-9-3 11:42

蔡州手游©2013-2025

快速回复 返回顶部 返回列表