您现在的位置是:首页 > 使用教程使用教程
苹果cms模板添加动态时钟与温馨问候语提示教程
【使用教程】
通过使用第三方API接口,我们可以方便的给WordPress添加动态时钟与温馨问候语提示方法,能够大大增强用户体验。

<div class="greeting-container">
<div class="clock-face">
<div class="clock-time" id="clock-time"></div>
</div>
<div class="greeting-text">
<div class="greeting" id="greeting"></div>
<div class="tip" id="tip"></div>
</div>
</div>
<style>
.greeting-container {
width: 100%;
height: 150px;
background-color: #f5f5f5;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
font-family: Arial, sans-serif;
}
.clock-face {
width: 100px;
height: 100px;
background-color: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.clock-time {
font-size: 24px;
font-weight: bold;
color: #333;
}
.greeting-text {
flex: 1;
margin-left: 20px;
}
.greeting {
font-size: 20px;
color: #007bff;
font-weight: bold;
margin-bottom: 10px;
}
.tip {
font-size: 16px;
color: #666;
line-height: 1.5;
}
</style>
<script>
function updateClock() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
document.getElementById('clock-time').textContent = `${hours}:${minutes}:${seconds}`;
}
function updateGreeting() {
fetch('https://api.ahfi.cn/api/getGreetingMessage?type=json')
.then(response => response.json())
.then(data => {
document.getElementById('greeting').textContent = data.data.greeting;
document.getElementById('tip').textContent = data.data.tip;
})
.catch(error => console.error('Error fetching the greeting message:', error));
}
document.addEventListener('DOMContentLoaded', function() {
updateClock();
updateGreeting();
setInterval(updateClock, 1000);
setInterval(updateGreeting, 60000);
});
</script> Tags:
相关文章
- 苹果cms模板帝国CMS后台登录成功后显示空白解决方法
- 苹果cms模板批量修改照片文件大小Python脚本
- 苹果cms模板精灵虚拟光驱是什么?精灵虚拟光驱怎么安装?苹果cms
- 苹果cms模板精灵虚拟光驱好用吗?精灵虚拟光驱怎么使用?苹果cms
- 苹果cms模板惠惠购物助手怎么用?惠惠购物助手不显示价格曲线怎么办?苹果cms
- 苹果cms模板windows media player是什么?windows media player服务器运行失败怎么解决?苹果cms
- 苹果cms模板360游戏大厅是什么?360游戏大厅怎么添加游戏?苹果cms
- 苹果cms模板360游戏大厅如何使用?360游戏大厅如何设置禁止自动启动?苹果cms
- 苹果cms模板excel2003有什么特点?excel2003表格怎么画斜线?苹果cms
- 苹果cms模板excel2003怎么使用?excel2003如何固定表头?苹果cms
