子比主题 – 侧边栏动态时间小工具

给大家带来一款子比主题的侧边栏动态时间小工具,这个小工具的效果还是比较炫酷的,当然每个人的眼光不同,有喜欢的可以自行部署。
演示效果:
子比主题 – 侧边栏动态时间小工具
代码部署:
本文隐藏内容
操作步骤:后台小工具→自定义HTML

<style>
  .times {
    margin: 0;
    padding: 0;
    height: 100%;
  }

  .times2 {
    height: 100%;
    background: #fff;
  }

  .times2 svg {
    height: 100%;
    width: 100%;
    margin-bottom: -34px;
  }

  .words {
    font-size: 60px;
    font-weight: bold;
    text-transform: uppercase;
    fill: none;
    stroke-width: 5px;
    stroke-dasharray: 90, 310;
    animation: drawing 8s linear infinite;
  }

  .words-1 {
    stroke: deepskyblue;
    text-shadow: 0 0 50px deepskyblue;
    animation-delay: -2s;
  }

  .words-2 {
    stroke: lightseagreen;
    text-shadow: 0 0 50px lightseagreen;
    animation-delay: -4s;
  }

  .words-3 {
    stroke: orange;
    text-shadow: 0 0 50px orange;
    animation-delay: -6s;
  }

  .words-4 {
    stroke: purple;
    text-shadow: 0 0 50px purple;
    animation-delay: -8s;
  }

  @keyframes drawing {
    100% {
      stroke-dashoffset: -400;
    }
  }
</style>

<div class="sidebox sidebox--desk">
  <div class="times">
    <div class="sidebox__content" style="padding: 0;">
      <div  style="border-radius:15px;" class="times2">
        <svg>
          <text text-anchor="middle" x="50%" y="50%" class="words words-1"></text>
          <text text-anchor="middle" x="50%" y="50%" class="words words-2"></text>
          <text text-anchor="middle" x="50%" y="50%" class="words words-3"></text>
          <text text-anchor="middle" x="50%" y="50%" class="words words-4"></text>
        </svg>
      </div>
    </div>
  </div>
</div>

<script>
  function showtime() {
    const now = new Date();
    let h = now.getHours();
    let m = now.getMinutes();
    let s = now.getSeconds();
    h = checktime(h);
    m = checktime(m);
    s = checktime(s);
    return `${h}:${m}:${s}`;
  }

  function checktime(x) {
    return x < 10 ? `0${x}` : x;
  }

  const texts = document.querySelectorAll("text");

  setInterval(() => {
    const time = showtime();
    texts.forEach(text => {
      text.textContent = time;
    });
  }, 1000);
</script>
温馨提示:本站提供的一切软件、教程和内容信息都来自网络收集整理,仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负,版权争议与本站无关。用户必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解! 联系邮箱:lgg.sinyi@qq.com

给TA打赏
共{{data.count}}人
人已打赏
CMS教程

WordPress 7B2/B2主题完美适应接入未认证微信公众号订阅号使用微信扫码登录教程

2025-9-4 19:34:09

其他媒体

最新首码项目,一键拉新有手就能做,几秒钟一单,1个小时单号可60+,矩阵批量做每天5张【揭秘】

2025-8-13 20:25:41

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索