WordPress侧边栏添加恋爱天数小工具

简介

图片[1]-WordPress侧边栏添加恋爱天数小工具-霖威小屋
说到情侣有纪念意义的恋爱天数,相信大多数情侣都会牢牢记住。因为这个过程是属于你们并且独一无二,成为永恒的记忆。下面代码可以记录你们在一起的天数,还能让你更懂得要珍惜眼前人哦~

子比主题】把下面代码展开复制粘贴到wp后台—外观—小工具—自定义HTML里面。

<!-- 恋爱计时 -->
<ul class="joe_header__slideout-count">
<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=你的QQ号&s=640" alt="love"
            style="width: 60px; border-radius: 50%;">
<!-- 中间的图片 -->
<img src="https://atbk.oss-cn-shanghai.aliyuncs.com/image/aotian/love.gif" alt="love"
            style="width: 60px; border-radius: 50%;">
<!-- 右边的头像 -->
<img src="https://q1.qlogo.cn/g?b=qq&nk=你对象的QQ号&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(2021, 04, 05, 21, 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>
</div>
</ul>

代码修改

图片[2]-WordPress侧边栏添加恋爱天数小工具-霖威小屋
将上图中的红框改成你QQ号和你对象的QQ
图片[3]-WordPress侧边栏添加恋爱天数小工具-霖威小屋
上面红框里面的改成你在一起的时间2021是年4是月5是日21是小时
00是分钟00是秒

效果图

图片[4]-WordPress侧边栏添加恋爱天数小工具-霖威小屋

同时子比主题支持自定义HTML代码添加到手机侧边菜单栏哦~

图片[5]-WordPress侧边栏添加恋爱天数小工具-霖威小屋
------本页内容已结束,喜欢请分享------

感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
喜欢就支持一下吧
点赞103赞赏 分享
评论 抢沙发

请登录后发表评论