gpt4 book ai didi

jquery - 在应用类之前更改CSS类不生效

转载 作者:行者123 更新时间:2023-12-01 07:43:12 26 4
gpt4 key购买 nike

对此已经有一段时间了,想知道是否有人可以指点一下:

本质上,我试图在将 css 动画的类应用到要动画的元素之前更新它,但类中更新的元素将不适用。在示例中,当我尝试动画时,迭代计数、持续时间和延迟不适用,但如果我已经将它们放在类中,它们就可以正常工作(它们现在已被注释掉)。

在应用动画之前有什么想法或其他方法来更新动画吗?我是否必须为动画的每个变体创建单独的类?”

谢谢。

$(document).ready(function(){
$(".blsAnimation").css("animation-iteration-count:", "1, 2, 1, 1");
$(".blsAnimation").css("animation-duration", "1s, 2s, 2s, 1s");
$(".blsAnimation").css("animation-delay", "1s, 1s, 6s, 7s");
$('#bls').addClass('blsAnimation');
});
/*circle for bls*/
.circle {
height: 10vw;
width: 10vw;
background: black;
border-radius: 50%;
margin: 0 auto;
margin-top: 40vh;
}

.blsAnimation {
animation-name: moveCenterLeft, moveLeftRight, moveLeftCenter, fadeOut;
/*animation-duration: 1000ms, 2000ms, 1000ms, 1000ms;*/
/*animation-delay: 1000ms, 2000ms, 6000ms,7000ms;*/
animation-timing-function: ease-in-out, ease-in-out, ease-in-out, ease-in-out;
/*animation-iteration-count: 1, 2, 1, 1;*/
animation-direction: normal, alternate, normal, normal;
animation-fill-mode: none, none, none, forwards;
}


/*animations for moving back and forth*/
@keyframes moveCenterLeft {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-40vw);
}
}

@keyframes moveLeftRight {
0% {
transform: translateX(-40vw);
}
100% {
transform: translateX(40vw);
}
}

@keyframes moveLeftCenter {
0% {
transform: translateX(-40vw);
}
100% {
transform: translateX(0vw);
}
}
<!DOCTYPE html>
<html lang="en">
<head>

<!-- If IE use the latest rendering engine -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta charset="UTF-8">
<title>Coach Rory</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<link rel="stylesheet" href="styles.css">
<script type='text/javascript' src="script.js"></script>
<script type ='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/screenfull.js/3.2.0/screenfull.min.js"></script>


</head>
<body>
<div>

<div class="circle" id = "bls"></div>

</div>
</body>
</html>

最佳答案

尝试用这个改变你的jquery代码。

$(document).ready(function(){
$('#bls').addClass('blsAnimation');
$(".blsAnimation").css({"animation-iteration-count": "1, 2, 1, 1","animation-duration": "1s, 2s, 2s, 1s","animation-delay": "1s, 1s, sideToSideDelay, fadeOutDelay"});
});

关于jquery - 在应用类之前更改CSS类不生效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44134566/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com