undefinedfix
Sign in

CSS3 background image looping

JYasir edited in Wed, 01 Jun 2022

The code is as follows, I want to let five pictures play in turn, and then loop, how to achieve this ah, ask for help, thank you

<div class="prologue">
    <div class="prologue__end">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</div>
.prologue__end div:nth-child(1) {
    background: url(../image/1.jpg) no-repeat center;
    background-size: contain;
}

.prologue__end div:nth-child(2) {
    background: url(../image/2.jpg) no-repeat center;
    background-size: contain;
}

.prologue__end div:nth-child(3) {
    background: url(../image/3.jpg) no-repeat center;
    background-size: contain;
}

.prologue__end div:nth-child(4) {
    background: url(../image/4.jpg) no-repeat center;
    background-size: contain;
}

.prologue__end div:nth-child(5) {
    background: url(../image/5.jpg) no-repeat center;
    background-size: contain;
}
.prologue .prologue__end div:nth-child(1) {
    animation: prologue__scale-box 2s ease 1.65s forwards;
    -webkit-animation: prologue__scale-box 2s ease 1.65s forwards;
}

.prologue .prologue__end div:nth-child(2) {
    animation: page__down-decoration 2s ease 3.8s forwards;
    -webkit-animation: page__down-decoration 2s ease 3.8s forwards;
}

.prologue .prologue__end div:nth-child(3) {
    animation: scale0-1 2s ease 6.8s forwards;
    -webkit-animation:;
}

.prologue .prologue__end div:nth-child(4) {
    animation: prologue__bloom-flower 2s ease 8.8s forwards;
    -webkit-animation: prologue__bloom-flower 2s ease 8.8s forwards;
}

.prologue .prologue__end div:nth-child(5) {
    animation: version-view__show-text-1 2s ease 10.8s forwards;
    -webkit-animation: version-view__show-text-1 2s ease 10.8s forwards;
}
2 Replies
MenInTheMiddle
commented on Wed, 01 Jun 2022

Use swiper, swiper

Juliette
commented on Thu, 02 Jun 2022

Without JS, you can use transform: translatex () to pan the width of an image at intervals

lock This question has been locked and the reply function has been disabled.