这段文本主要讲述了如何将旋转小人的动画效果引入到Hexo主题中。首先,在themes/butterfly/layout/includes/widget中创建一个名为card_anim.pug的文件,并将旋转小人的代码复制到该文件中。然后,在themes/butterfly/layout/includes/widget/index.pug中引入刚刚创建的文件。最后,重新启动服务,即可看到旋转小人的动画效果。
加载中...此内容根据文章生成,并经过人工审核,仅用于文章内容的解释与总结
旋转小人
下面是codepen中的代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <div class="twopeople"> <div class="container" style="height:200px;"> <canvas class="illo" width="800" height="800" style="max-width: 200px; max-height: 200px; touch-action: none; width: 640px; height: 640px;"></canvas> </div> <script src="https://cdn.jsdelivr.net/gh/Justlovesmile/CDN/js/twopeople1.js"></script> <script src="https://cdn.jsdelivr.net/gh/Justlovesmile/CDN/js/zdog.dist.js"></script> <script id="rendered-js" src="https://cdn.jsdelivr.net/gh/Justlovesmile/CDN/js/twopeople.js"></script> <style> .twopeople{ margin: 0; align-items: center; justify-content: center; text-align: center; } canvas { display: block; margin: 0 auto; cursor: move; } </style> </div>
|
引入到Hexo主题中
在themes/butterfly/layout/includes/widget
中创建一个文件命名为card_anim.pug
在文件中复制以下代码
1 2 3 4 5 6 7
| .twopeople(style="margin: 0;align-items: center;justify-content: center;text-align: center;") .container(style="height: 180px; margin: 0; align-items: center; justify-content: center; text-align: center;") canvas.illo(width="600" height="600" style="display: block;margin: 0 auto;cursor: move;max-width: 200px; max-height: 200px; touch-action: none; width: 480px; height: 480px;") <script src="https://npm.elemecdn.com/justlovesmile-static/js/twopeople1.js"></script> <script src="https://npm.elemecdn.com/justlovesmile-static/js/zdog.dist.js"></script> <script id="rendered-js" src="https://npm.elemecdn.com/justlovesmile-static/js/twopeople.js"></script>
|
在themes/butterfly/layout/includes/widget/index.pug
中引入我们刚刚添加的文件到页面,+号的是引入的文件,记得把+号删除
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 30 31 32
| #aside-content.aside-content if is_post() - const tocStyle = page.toc_style_simple - const tocStyleVal = tocStyle === true || tocStyle === false ? tocStyle : theme.toc.style_simple if showToc && tocStyleVal .sticky_layout include ./card_post_toc.pug else !=partial('includes/widget/card_author', {}, {cache: true}) !=partial('includes/widget/card_announcement', {}, {cache: true}) !=partial('includes/widget/card_top_self', {}, {cache: true}) else !=partial('includes/widget/card_author', {}, {cache: true}) !=partial('includes/widget/card_announcement', {}, {cache: true}) !=partial('includes/widget/card_top_self', {}, {cache: true})
+include ./card_anim.pug
.sticky_layout if !is_post() if showToc include ./card_post_toc.pug .card-widget !=partial('includes/widget/card_ad', {}, {cache: true}) !=partial('includes/widget/card_categories', {}, {cache: true}) !=partial('includes/widget/card_tags', {}, {cache: true}) !=partial('includes/widget/card_archives', {}, {cache: true}) !=partial('includes/widget/card_webinfo', {}, {cache: true}) !=partial('includes/widget/card_bottom_self', {}, {cache: true}) else include ./card_post_toc.pug include ./card_recent_post.pug
|
添加完成之后重新启动服务就可以看到效果了