У меня есть следующие HTML
и CSS
код:
.parent{
height: 10%;
width: 100%;
float: left;
position: relative;
}
.content1{
height: 100%;
width: 20%;
background-color: blue;
float: left;
position: absolute;
}
.content2{
height: 100%;
width: 20%;
background-color: red;
float: left;
animation-delay: 1s;
position: absolute;
}
.content3{
height: 100%;
width: 20%;
background-color:yellow;
float: left;
animation-delay: 2s;
position: absolute;
}
.content4{
height: 100%;
width: 20%;
background-color: green;
float: left;
animation-delay: 3s;
position: absolute;
}
.content5{
height: 100%;
width: 20%;
background-color: orange;
float: left;
animation-delay: 4s;
}
.parent div {
animation-name: animation_01;
animation-duration:2s;
animation-iteration-count:infinite;
animation-fill-mode: forwards;
opacity:0;
}
@keyframes animation_01 {
0% {
opacity: 0
}
50% {
opacity: 1
}
100% {
opacity: 0
}
}
<div class="parent">
<div class="content1">Here goes content1</div>
<div class="content2">Here goes content2</div>
<div class="content3">Here goes content3</div>
<div class="content4">Here goes content4</div>
<div class="content5">Here goes content5</div>
</div>
Как вы можете видеть в коде, я отображаю 5 содержимого друг над другом, используя анимацию keyframes
.Я хочу запустить эту анимацию бесконечно, поэтому я поставил animation-iteration-count:infinite;
.
Однако, как только анимация достигает content5
, она не возвращается к content1
и начинается заново.Вместо этого он возвращается только к content4
и затем показывает / скрывает content4
и content5
в бесконечном цикле.
Что мне нужно изменить в моем коде, чтобы анимация вернулась к content1
и снова запускает анимацию?