本站已运行时间动态渐变颜色代码

图片[1]-本站已运行时间动态渐变颜色代码-极客源码

代码直接插入子比主题适当的位置,我没用这个代码 我感觉是放在子比后台全局——CSS

 /*本站已运行时间渐变颜色代码*/
<span style="margin-left: 5px;" id="showsectime">已安全运行:56天15小时52分47秒</span>

这个代码应该是放到外观–小工具–自定义HTML,放进去没效果就删掉

 /*本站已运行时间渐变颜色核心代码*/
<script type="text/javascript">
    function NewDate(str) {
      str = str.split('-');
      var date = new Date();
      date.setUTCFullYear(str[0], str[1] - 1, str[2]);
      date.setUTCHours(0, 0, 0, 0);
      return date;
    }
    function showsectime() {
      var birthDay = NewDate("2022-1-1");
      var today = new Date();
      var timeold = today.getTime() - birthDay.getTime();
      var sectimeold = timeold / 1000
      var secondsold = Math.floor(sectimeold);
      var msPerDay = 24 * 60 * 60 * 1000; var e_daysold = timeold / msPerDay;
      var daysold = Math.floor(e_daysold);
      var e_hrsold = (daysold - e_daysold) * -24;
      var hrsold = Math.floor(e_hrsold);
      var e_minsold = (hrsold - e_hrsold) * -60;
      var minsold = Math.floor((hrsold - e_hrsold) * -60); var seconds = Math.floor((minsold - e_minsold) * -60).toString();
      document.getElementById("showsectime").innerHTML = "已安全运行:" + daysold + "天" + hrsold + "小时" + minsold + "分" + seconds + "秒";
      setTimeout(showsectime, 1000);
    } showsectime();
  </script>
</div>
<style>
  #showsectime {
    animation: change 10s infinite;
    font-weight: 800;
  }

  @keyframes change {
    0% {
      color: #5cb85c;
    }

    25% {
      color: #556bd8;
    }

    50% {
      color: #e40707;
    }

    75% {
      color: #66e616;
    }

    100% {
      color: #67bd31;
    }
  }
</style>
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容