【问题标题】:How to enable Animate.css in Wordpress如何在 Wordpress 中启用 Animate.css
【发布时间】:2019-05-01 03:02:50
【问题描述】:

我已按照一些说明从该 CDN:https://cdnjs.com/libraries/animate.css/ 排队 Animate.css。我在 functions.php wordpress 文件中引用了第二个选项:https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css

当我在我的网站上加载页面时,引用似乎出现在我的页面中,但是当我将 Animate.css 类添加到图像或 div 时,它不会像预期的那样为元素设置动画。

这是我添加到我的 functions.php 文件中的代码:

function enqueue_my_custom_styles() {
    wp_enqueue_style( 'animate-css', 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css', false ); 
}

add_action( 'wp_enqueue_scripts', 'enqueue_my_custom_styles' );

Here's a page where I've added the "pulse" class 指向下载图标/图像,但它没有跳动。

【问题讨论】:

标签: php css wordpress animate.css


【解决方案1】:

在您的 function.php 文件中执行以下操作:

/** * 从 MaxCDN 加载 Animate CSS - 正确的方式 * */

function load_animate_css() {
  // Load Boostrap CSS
  wp_enqueue_style( 'animate-css', 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css' );

  // Load Css
  wp_enqueue_style( 'style', get_stylesheet_uri() );

}
add_action( 'wp_enqueue_scripts', 'load_animate_css' );

要让动画工作,请将 animated 类添加到 pulse 类,如果您希望动画循环工作,请添加 infinite 类。 所以 img 标签将有以下类。

<img src="" class="pluse infinite animated"/>

【讨论】:

  • 我试图删除我在 functions.php 中的所有代码并用你的代码替换它,但它仍然没有工作。我想知道我可能还缺少什么?
  • 我认为你错过了一些课程,因为 animate.css 正在加载
  • 您是正确的,我使用我在 OP 中提供的代码错误地加载了我的 CSS。添加“动画”和“无限”类正是我所需要的!非常感谢!
  • 一个后续问题...我喜欢动画无限循环,但我正在使用 CDN,我想知道是否有办法通过内联样式将动画延迟指定的持续时间。例如➞ 我希望动画每 6 秒重复一次。
  • 我在这里问了这个问题stackoverflow.com/questions/53544967/… 并且一位绅士提供了一个链接到一篇文章的链接,该文章概述了我正在尝试做的事情,但我不确定如何以最简单的方式实现它.您知道我如何轻松实现它吗?
【解决方案2】:

问题在于链接标签

"`<link rel="stylesheet" id="animate-css" href="https://jewelbound.com/wp-content/themes/course-builderhttps://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css" type="text/css" media="all">`"

/themes/course-builderhttps://cdnjs.cloudflare.com/

【讨论】:

  • 有趣!那么我需要改变什么(以及在哪里)来解决这个问题?
  • 你应该避免这样的答案。您应该提供针对该问题的建议修复的完整答案。
  • 对不起,我是一名设计师兼 HTML/CSS 开发人员,提问者没有提到他知道这个问题,因为他很可能错过了这个问题。我只是想尽我所能,因为除了 HTML/CSS/LESS 之外,我不知道任何脚本或编程语言。
  • 拆分 href 引用,因为现在看起来就像两把剑合二为一。 'jewelbound.com/wp-content/themes/course-builder" rel="stylesheet" type="text/css" />' 和 'cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/…" rel="stylesheet" type="text/css" /> '。
  • 或者如果你有一个自定义样式表,你可以在那里导入 animate.css。它仍然可以工作
猜你喜欢
  • 2021-06-06
  • 1970-01-01
  • 2014-09-10
  • 2021-11-07
  • 2014-02-10
  • 1970-01-01
  • 2015-04-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多