动画.css - 它是如何工作的?如何使其自动工作
Animate.css - How does it work? How to make it work automatically?
我正在尝试实现从 https://daneden.me/animate/到我的网站的bounceinUp。
我没有单击按钮,而是尝试将其放在div 框中,该框将在 2-3 秒后自动执行上述操作。
.HTML
<div class="" id="animateTest">
<p style="opacity: 0.8;" data-test="bounceinUp">Testing</p>
</div>
.CSS
@-webkit-keyframes bounceInUp {
0% {
opacity: 0;
-webkit-transform: translateY(2000px);
}
60% {
opacity: 1;
-webkit-transform: translateY(-30px);
}
80% {
-webkit-transform: translateY(10px);
}
100% {
-webkit-transform: translateY(0);
}
}
@-moz-keyframes bounceInUp {
0% {
opacity: 0;
-moz-transform: translateY(2000px);
}
60% {
opacity: 1;
-moz-transform: translateY(-30px);
}
80% {
-moz-transform: translateY(10px);
}
100% {
-moz-transform: translateY(0);
}
}
@-o-keyframes bounceInUp {
0% {
opacity: 0;
-o-transform: translateY(2000px);
}
60% {
opacity: 1;
-o-transform: translateY(-30px);
}
80% {
-o-transform: translateY(10px);
}
100% {
-o-transform: translateY(0);
}
}
@keyframes bounceInUp {
0% {
opacity: 0;
transform: translateY(2000px);
}
60% {
opacity: 1;
transform: translateY(-30px);
}
80% {
transform: translateY(10px);
}
100% {
transform: translateY(0);
}
}
.bounceInUp {
-webkit-animation-name: bounceInUp;
-moz-animation-name: bounceInUp;
-o-animation-name: bounceInUp;
animation-name: bounceInUp;
}
#animateTest {
-webkit-animation-duration: 1s;
-webkit-animation-delay: .2s;
-webkit-animation-timing-function: ease;
-webkit-animation-fill-mode: both;
-moz-animation-duration: 1s;
-moz-animation-delay: .2s;
-moz-animation-timing-function: ease;
-moz-animation-fill-mode: both;
-ms-animation-duration: 1s;
-ms-animation-delay: .2s;
-ms-animation-timing-function: ease;
-ms-animation-fill-mode: both;
-o-animation-duration: 1s;
-o-animation-delay: .2s;
-o-animation-timing-function: ease;
-o-animation-fill-mode: both;
animation-duration: 1s;
animation-delay: .2s;
animation-timing-function: ease;
animation-fill-mode: both;
}
我认为这是javascript,尽管它没有显示在页面上(并且没有我搜索的有关javascript的教程)。
<script>
function testAnim(x) {
$('#animateTest').removeClass().addClass(x);
var wait = window.setTimeout( function(){
$('#animateTest').removeClass()},
1300
);
}
</script>
无论如何,当我这样做时,它对它没有任何作用。我想知道我做错了什么?很抱歉,如果这听起来很简单,我才刚刚开始学习HTML和javascript。
提前感谢,
这是你的代码的小提琴 - http://jsfiddle.net/yd79L/1/您的问题是您在创建函数后忘记调用该函数。还要记住,如果你想让一个函数去"循环"——它应该从内部调用自己
。同样在您的代码中,您只有 (x) 作为函数的参数,您需要指定要使用的类的名称
function testAnim(x) {
$('#animateTest').removeClass().addClass(x);
var wait = window.setTimeout( function(){
$('#animateTest').removeClass(x);
}, 1300
);
window.setTimeout(function(){ // this code calls the function and makes it cycle
testAnim(x);
}, 2000 );
}
testAnim('bounceInUp');
相关文章:
- 如何使用javascript操作SVG节点,使其在MS Edge中工作
- 扩展在LeafletJS中是如何工作的,为什么我需要一个中介归因才能使其正确工作
- 应该怎么做才能使其在IE7中工作
- 如何实现nanoScroller,使其正确工作
- Elastislide-如何使其在不同的图像宽度下工作
- JS滑块计数器不工作..需要找到一种方法使其正常工作
- 动画.css - 它是如何工作的?如何使其自动工作
- 低级反应动画 API 无法使其工作
- 如何重写此联系人按钮代码以使其正常工作
- 如何将代码分成两个文件,并仍然使其在node.js中工作
- Jasmine spyOn:当传递间谍函数引用时如何使其工作
- 我想在js文件中包含$(document).keydown(function (e) {,但我无法使其工作
- 将结果从.html(或innerHtml)输入到inArray并使其工作
- 我在哪里放置此JS代码以使其工作
- 如何在博客中的帖子标题下方显示广告,使其即使在博客的移动版上也能工作
- Javascript:代码片段,无法使其工作(设置和读取cookie)
- 基于字符串搜索的简单jquery查找和显示无法使其工作
- Ajax表单-仍然无法使其与验证一起工作
- 数组错误如何使其工作
- Javascript:XMLHttpRecust:如何使其工作