因此,我使用 @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;
}
}
最佳答案
您需要设置迭代次数:
animation-iteration-count: 2; // 0-infinite
https://www.w3schools.com/cssref/css3_pr_animation-iteration-count.asp
关于html - 为什么@keyframe 动画只工作一次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58109341/