侧边栏显示倒计时
代码/usr/themes/handsome/component/sitebar.php
大约第26行位置添加
<style> .gn_box{ border: none; border-radius: 10px; } .gn_box { padding: 8px 10px; margin: 8px; margin-bottom: 15px; text-align: center; background-color: ; } #t_d{ color: grey; font-size: 18px; } #t_h{ color: grey; font-size: 18px; } #t_m{ color: grey; font-size: 18px; } #t_s{ color: grey; font-size: 18px; } </style> <div class="gn_box"> <h3>距2023年高考还有</h3><center> <div id="CountMsg" class="HotDate"><span id="t_d"> 天</span><span id="t_h"> 时</span><span id="t_m"> 分</span><span id="t_s"> 秒</span></div></center> <script type="text/javascript"> function getRTime() { var EndTime = new Date('2023/06/7 00:09:00'); var NowTime = new Date(); var t = EndTime.getTime() - NowTime.getTime(); var d = Math.floor(t / 1000 / 60 / 60 / 24); var h = Math.floor(t / 1000 / 60 / 60 % 24); var m = Math.floor(t / 1000 / 60 % 60); var s = Math.floor(t / 1000 % 60); var day = document.getElementById("t_d"); if (day != null) { day.innerHTML = d " 天"; } var hour = document.getElementById("t_h"); if (hour != null) { hour.innerHTML = h " 时"; } var min = document.getElementById("t_m"); if (min != null) { min.innerHTML = m " 分"; } var sec = document.getElementById("t_s"); if (sec != null) { sec.innerHTML = s " 秒"; } } setInterval(getRTime, 1000); </script> </div></img>
在主题设置-开发者设置-自定义输出body 尾部的HTML代码 下载js文件: https://cos.xpblog.cn/cos-for-xpbloger/handsome8.3.0Pro/assets/js/timeinfo.js
代码语言:javascript复制<!-- 倒计时引用的JS -->
<script src="js的地址"></script>
<!-- 倒计时引用的JS -->