网站添加恋爱计时侧边栏小组件 - 陌路人博客

网站添加恋爱计时侧边栏小组件-陌路人博客-第1张图片陌路人

陌路人博客(molure.cn)
用心传递快乐,初心不变。

网站添加恋爱计时侧边栏小组件

网站添加恋爱计时侧边栏小组件-陌路人博客- 第3张图片

1.一个可以让你网站侧栏不在那么孤单的代码


2.支持修改代码中的qq号即可更改头像图片,自定义恋爱计时


3.放进自定义侧边栏组件里就可以使用。


    <!-- 恋爱计时 -->
        <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=8670468&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=8670468&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(2019, 10, 19, 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>
        </div>
        </ul>



×

感谢您的支持,我们会一直保持!

网站添加恋爱计时侧边栏小组件-陌路人博客- 第5张图片
请土豪扫码随意打赏

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

打赏作者
版权所有,转载注意明处:陌路人博客 » 网站添加恋爱计时侧边栏小组件
标签: 教程 代码

发表评论

表情
看不清楚?点图切换

网友评论(0)