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

标签 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/

最佳答案

您需要设置迭代次数:

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/

相关文章:

html - YouTube Iframe API:无法在IOS上自动播放

javascript - 在 Internet 区域处于高安全模式时,网站在 IE8 中出现乱码

javascript - 如何删除没有值(value)的选项选择?

javascript - 为什么我不能让汉堡菜单正常工作?

javascript - 输入栏在几秒钟后消失

css - SVG 动画步进旋转

html - 快速调整以使无聊的独立 Web 表单看起来更好?

javascript - 我将如何使用 Canvas 包装我的文字?

jquery - 如何创建循环图像滚动效果

html - CSS 动画在 Github wiki 页面中不起作用