lambsbaaacode
lambsbaaacode

Reputation: 70

why is @keyframe animation only working once?

So I removed opacity from the css code from the answer to my last question with @keyframe animation and it's only working once for some reason. Help?

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/

Upvotes: 1

Views: 152

Answers (1)

Alex
Alex

Reputation: 2800

You need to set the iteration count:

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

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

Upvotes: 1

Related Questions