2020-10-31

How to run CSS animation of two keyframes continuously

I would like to run my animation consisting of two keyframes to mimic the motion of a closing garage door, but the animation stops after one execution. Adding animation-iteration-count: 10; just flashes the 'door', doesn't rerun the whole animation. What could be the issue? Thank you in advance!

.house {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 150px;
}

.house .front {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 5.2em;
    height: 4em;
    border-left: 0.5em solid grey;
    border-right: 0.5em solid grey;
}

.house .front .gable {
    position: absolute;
    top: -3.5em;
    left: 50%;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-left: 3.1em solid transparent;
    border-right: 3.1em solid transparent;
    border-bottom: 3.5em solid grey;
}

.house .front .door {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4.2em;
    height: 0.4em;
    background: grey;
    border-radius: 2px 2px 0 0;
    overflow: hidden;
}

.house .front .door:before {
    content: '';
    display: block;
    width: 40%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: black;
}

.house .front #d1 {
    transform: translateX(-50%) translateY(-80%);
}

.house .front #d2 {
    transform: translateX(-50%) translateY(-300%);
}

.house .front #d3 {
    transform: translateX(-50%) translateY(-540%);
}

.house .front #d4 {
    transform: translateX(-50%) translateY(-800%);
}

.house .front .doors .door {
    animation-name: hide, up;
    animation-duration: 1.6s;
    animation-timing-function: ease-in;
    animation-iteration-count: 1;
    opacity: 1;
}

.house .front .doors #d4 {
    animation-delay: 0s, 0s;
}

.house .front .doors #d3 {
    animation-delay: 0s, 0.3s;
}

.house .front .doors #d2 {
    animation-delay: 0s, 0.6s;
}

.house .front .doors #d1 {
    animation-delay: 0s, 0.9s;
}

@keyframes hide
{ 
    from { opacity: 0; } to { opacity: 0 }
}
@keyframes up
{ 
    0% { opacity: 0; }
    1% { opacity: 1; }
    100% { opacity: 1; } 
} 
<div class="house">
    <div class="front">
        <div class="gable"></div>
        <div class="doors">
            <div id="d1" class="door"></div>
            <div id="d2" class="door"></div>
            <div id="d3" class="door"></div>
            <div id="d4"class="door"></div>            
        </div>
    </div>
</div>

sorry for this part, but SO wouldn't let me post this question unless more text is added.



from Recent Questions - Stack Overflow https://ift.tt/34KL3uu
https://ift.tt/eA8V8J

No comments:

Post a Comment