效果展示
教程
将下面代码粘贴到主题-开发者设置-自定义 JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <!--恋爱记时--> function lovexhjSitetime() { window.setTimeout("lovexhjSitetime()", 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(2020, 04, 15, 15, 15, 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("lovexhjSitetime").innerHTML = "我们相恋了" + diffYears + "年" + diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒啦" } lovexhjSitetime()
|
以下代码粘贴到全局右侧广告位
即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <aside class="widget_text sidebar-widget widget_custom_html fadeInUp"> <div class="textwidget custom-html-widget"> <div id="lovexhj" style="width: 100%; height: 100px; text-align: center; font-size: 1rem;"> <div id="lovexhjImage" style="width: 220px; margin: 0 auto;"> <!-- 左边的头像 --> <img src="https://cdn.siax.cn/npm/picture-sianx@1.0.0/2020/09/18/ce811c68ff1b4eb9a5b6d2a784d07c31.png" alt="love" style="width: 60px; border-radius: 50%;"> <!-- 中间的图片 --> <img src="https://cdn.siax.cn/npm/picture-sianx@1.0.0/2020/09/18/lovelogo%20.gif" alt="love" style="width: 60px; border-radius: 50%;"> <!-- 右边的头像 --> <img src="https://cdn.siax.cn/npm/picture-sianx@1.0.0/2020/09/18/3db15cc33adda3afcdbc62e18fc8403f.png" alt="love" style="width: 60px; border-radius: 50%;"> </div> <p id="lovexhjSitetime" style="font-size: 0.8rem; margin-top: 16px; background: linear-gradient(to right, red, blue);-webkit-background-clip: text;color: transparent;">我们相恋了104天14小时47分钟19秒啦</p> </div> </div> </aside>
|
侧边广告栏名字在usr/themes/handsome/component/sidebar.php
文件中修改。
爱心图标
可用于替换中间猫抓的图片。
1
| <img class="couple-love" src="https://cdn.siax.cn/npm/picture-sianx@1.0.7/img/love.png" alt="爱心">
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| .couple-love { width: 35px; margin: 20px 0; animation: heartbeat 1.33s ease-in-out infinite; }
@keyframes heartbeat { 0% { -webkit-transform: scale(1); transform: scale(1) } 50% { -webkit-transform: scale(.8); transform: scale(.8) } to { -webkit-transform: scale(1); transform: scale(1) } }
|
最后,代码有了,对象在哪领,麻烦知情人士认识告诉我一下。