场景:
我有一个动画,当我的背景视频变得非常明亮时,我的文本将变黑。
问题:
背景视频切换回开头后,文本保持为黑色。如何重新设置?
目标:
我希望我的keyframe
动画在几秒钟后重新启动。
问题:
有解决方案吗?
我的代码:HTML:
<div class="header-text">
<h1 class="head-text">Rico Dijkstra</h1>
<h2 class="head-desc">Front-end</h2>
</div>
CSS:
.header-text {
display: flex;
flex-direction: column;
float: right;
text-align: right;
align-content: center;
justify-content: center;
}
.head-text {
font-family: 'Lato', ;
color: white;
float: right;
font-size: 4rem;
animation-name: color-swap;
animation-duration: 3s;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
.head-desc {
font-family: 'Lato', ;
color: white;
float: right;
font-size: 3rem;
animation-name: color-swap;
animation-duration: 3s;
animation-delay: 4.5s;
animation-fill-mode: forwards;
margin-top: 0;
}
@keyframes color-swap {
from {color: white;}
to {color: black}
}
您可以使用jQuery SetInterval尝试为此,您不需要在开头包含动画cssCSS:
.header-text {
display: flex;
flex-direction: column;
float: right;
text-align: right;
align-content: center;
justify-content: center;
}
.head-text {
font-family: 'Lato', ;
color: white;
float: right;
font-size: 4rem;
}
.head-desc {
font-family: 'Lato', ;
color: white;
float: right;
font-size: 3rem;
margin-top: 0;
}
@keyframes color-swap {
from {color: white;}
to {color: black}
jquery
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
setInterval(function(){
$(".head-text .head-desc").css({
"animation-name":"color-swap",
"animation-duration": "3s",
"animation-fill-mode": "forwards"})
}, 3000);
}
</script>