为什么@keyframe动画只能工作一次?

时间:2019-09-26 03:54:26

标签: html css css-animations

所以我用@keyframe动画从最后一个问题的答案的css代码中消除了不透明度,由于某种原因,它只能工作一次。帮助吗?

header {
transition: height 600ms ease-in;
animation: yourAnimation 1s forwards 1s ease;

/* Define the dropdown-content transition styles on opacity, where
the opacity delay causes opacity of menu items to change after menu
animation (of 1sec) is complete */
.dropdown-content  {
display: grid;
    animation: yourAnimation 1s forwards 1s ease;
}

/* CSS modifier class for "header.open" causes height to change
when open class applied */
&.open {
height: 100%;
grid-template-rows: 50px 400px;
grid-row-gap: 20px;
grid-template-areas: 'dp logo start' 'dc dc dc';
}

/* When open modifier class applied to parent header, items in the
.dropdown-content child are set to be opaque/visible */
&.open .dropdown-content {
opacity: 1.0;
    animation: yourAnimation 1s forwards 1s ease;
}
}

JSFiddle:https://jsfiddle.net/lambsbaaacode/1bxnzcsr/

1 个答案:

答案 0 :(得分:1)

您需要设置迭代次数:

animation-iteration-count: 2; // 0-infinite

https://www.w3schools.com/cssref/css3_pr_animation-iteration-count.asp