先贴一下代码,下面有打包的文件下载。

  1. // 封装代码
  2. function meihua() { ?>
  3. <!-- 加载snowfall.js -->
  4. <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/hua/snowfall.js"></script>
  5. <!-- 梅花枝,可以删除 -->
  6. <div class="meiha"></div>
  7. <!-- 配套样式,可以替换其中的图片地址 -->
  8. <style>
  9. /** 梅花枝 **/
  10. .meiha {
  11. position: fixed;
  12. top: 0;
  13. right: 0;
  14. z-index: 999;
  15. width: 350px;/** PNG图宽度 **/
  16. height: 231px;/** PNG图高度 **/
  17. pointer-events: none;
  18. background: url('https://s2.ax1x.com/2020/01/21/1kBpid.png');
  19. }
  20.  
  21. /** 梅花翻转动画 **/
  22. .snowfall-flakes {
  23. pointer-events: none;
  24. animation: sakura 1s linear 0s infinite;
  25. }
  26.  
  27. .snowfall-flakes {
  28. animation: sakura 1s linear 0s infinite;
  29. }
  30.  
  31. .night .snowfall-flakes {
  32. background: transparent !important;
  33. }
  34.  
  35. @keyframes sakura {
  36. 0% {
  37. transform: rotate3d(0, 0, 0, 0deg);
  38. }
  39.  
  40. 25% {
  41. transform: rotate3d(1, 1, 0, 60deg);
  42. }
  43.  
  44. 50% {
  45. transform: rotate3d(1, 1, 0, 0deg);
  46. }
  47.  
  48. 75% {
  49. transform: rotate3d(1, 0, 0, 60deg);
  50. }
  51.  
  52. 100% {
  53. transform: rotate3d(1, 0, 0, 0deg);
  54. }
  55. }
  56. </style>
  57. <?php }
  58. /** 将代码绑定到页脚 **/
  59. add_action( 'wp_footer', 'meihua', 100 );

以上代码可以替换打包下载的hua.php文件中的内容,图片居右显示。

使用方法:文章源自知更鸟-https://zmingcx.com/falling-petals-in-wordpress.html

第一步,解压文件将hua文件夹上传到当前主题根目录中。文章源自知更鸟-https://zmingcx.com/falling-petals-in-wordpress.html

第二步,打开当前主题页脚模板footer.php,在<?php wp_footer(); ?>上面添加:



微信扫描下方的二维码阅读更多精彩内容

https://snxa.com/wp-content/plugins/rest-api-to-wechat/images/qrcode/qrcode-3223.png