返回列表 发布新帖
查看: 113|回复: 0

[HTML代码] 时间样式带文案的html代码

154

主题

280

回帖

745

积分

管理员

UID
13
0 糖
威望
1 点
贡献
1466713630 点
宣传
1 点
买家信用
0 点
卖家信用
0 点
注册时间
2024-2-1
在线时间
142 小时

实名认证终身成就勋章多玩论坛技术勋章管理团队勋章秘书勋章

发表于 2024-7-20 20:27:09 | 查看全部 |阅读模式
图片展示:




需要有html代码权限  
  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>
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
一花一世界,一叶一追寻。一曲一场叹,一生为一人。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

投诉/建议联系

15164@126.com

欢迎各位朋友加入本社区,
共同维护良好的社区氛围
  • 扫码添加QQ
  • 添加微信客服
Copyright © 2001-2025 多玩论坛 dwlt_cn 版权所有 All Rights Reserved.
关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表