为博客添加动态弹簧人物效果
标签搜索

为博客添加动态弹簧人物效果

初白
2024-07-06 / 5 评论 / 138 阅读 / 正在检测是否收录...

今天就来说一下博客怎么添加GitHub上sakana大佬的开源项目


添加弹簧人物的步骤
找到主题编辑器,在 footer.php 添加如下代码即可

<div class="sakana-box"></div>
    <script src="https://cdn.jsdelivr.net/npm/sakana"></script>
    <script>
        // 启动
        const sakana = Sakana.init({
          el:         '.sakana-box',     // 启动元素 node 或 选择器
          scale:      .5,                // 缩放倍数
          canSwitchCharacter: true,      // 允许换角色
          inertia:    0.01,              // 惯性
          decay:      0.97,              // 衰减
          r:          -20,                // 启动角度
          y:          10,                // 启动高度
          scale:      0.5,                 // 缩放倍数
          translateY: 0,                 // 位移高度
        });
    </script>
     
    <style>
        html .sakana-box{
            z-index: 80;
            position: fixed;
            right: 0;
            bottom: 0;
            transform-origin: 100% 100%; /* 从右下开始变换 */
        }
    </style>

如果弹簧人物加载缓慢,可以将 js 文件下载到本地

2

评论 (5)

取消
  1. 头像
    qyijobmgxf
    Windows 10 · Google Chrome

    这篇文章不错!

    回复
  2. 头像
    yesgthikmu
    Windows 10 · Google Chrome

    这是一篇佳作,无论是从内容、语言还是结构上,都堪称完美。

    回复
  3. 头像
    pqnvshmaon
    Windows 10 · Google Chrome

    作者的才华横溢,让这篇文章成为了一篇不可多得的艺术品。

    回复
  4. 头像
    psihhculul
    Windows 10 · Google Chrome

    幽默外壳包裹严肃内核,寓教于乐。

    回复
  5. 头像
    rgxgrlkdvj
    Windows 10 · Google Chrome

    情感真挚自然,字里行间传递出强烈的感染力。

    回复