网站侧栏添加单身/情侣计时

最近博主在QQ群打开一个博客,看了看觉得这侧栏不错就顺手盗了,喜欢的朋友收藏哦!

步骤一

新建一个jishi.HTML文件到根目录,复制下面代码进去保存即可

<!DOCTYPE html>  <html>  <head>      <meta charset="utf-8">      <meta name="viewport" content="width=device-width">      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />      <meta name="renderer" content="webkit">      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />      <title>忘心</title>      <style>          body {              -webkit-font-smoothing: antialiased;              font-family: Helvetica Neue, Helvetica, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;              background-image: url('背景图片链接');              font-size: 85%;              margin: 0;          }                    h2 {              font-size: 220%;              font-weight: 400;          }                    .content {              position: absolute;              width: 100%;              top: 40%;              transform: translate(0, -50%);              text-align: center;          }                    .timer {              font-size: 180%;              line-height: 1.5;              margin: 1em 0;          }                    .timer b {              color: rgb(253, 99, 125);          }      </style>  </head>    <body>     <div id="lovexhj" style="width: 100%; height: 100%; text-align: center; font-size: 1rem;">          <div id="lovexhjImage" style="width: 220px; margin: 0 auto;">          <!-- 左边的头像 -->          <img src="https://q1.qlogo.cn/g?b=qq&nk=898623239&s=640" alt="love"              style="width: 60px; border-radius: 50%;">          <!-- 中间的图片 -->          <img src="https://cdn.jsdelivr.net/gh/aill66/cdn/love.gif" alt="love"              style="width: 60px; border-radius: 50%;">          <!-- 右边的头像 -->          <img src="https://q1.qlogo.cn/g?b=qq&nk=898623239&s=640" alt="love"              style="width: 60px; border-radius: 50%;">          </div>          <p id="loveSitetime" style="font-size: 1.0rem;"></p>                  <script language=javascript>          function loveSitetime() {              window.setTimeout("loveSitetime()", 1000);              var seconds = 1000              var minutes = seconds * 60              var hours = minutes * 60              var days = hours * 24              var years = days * 365              var today = new Date()              var todayYear = today.getFullYear()              var todayMonth = today.getMonth() + 1              var todayDate = today.getDate()              var todayHour = today.getHours()              var todayMinute = today.getMinutes()              var todaySecond = today.getSeconds()              // 时间设置              var t1 = Date.UTC(2002, 09, 27, 00, 00, 00)              var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond)              var diff = t2 - t1              var diffYears = Math.floor(diff / years)              var diffDays = Math.floor((diff / days) - diffYears * 365)              var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours)              var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) / minutes)              var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -                  diffMinutes * minutes) / seconds)              document.getElementById("loveSitetime").innerHTML = "我已单身:</br>" + diffYears + "年" + diffDays + "天" +                  diffHours + "时" + diffMinutes + "分" + diffSeconds + "秒啦</br>"          }          loveSitetime()          </script>       <iframe src="https://t1.kugou.com/song.html?id=56iYZaexWV2" allow="autoplay" hidden/>  </body>    </html>

保存后我们开始调用

步骤二

<object type="text/html" data="./jishi.html" width="100%" height="100%"></object>

然后把代码放入到你博客的header.php 文件里

由于不是每人的主题都一样,就不细说放在哪里了,如果有不会的,在下方留言,或者联系我。

相关文章

您需要 登录账户 后才能发表评论

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注