Pure CSS to achieve automatic rotation effect of carousel banner

Pure CSS to achieve automatic rotation effect of carousel banner

Without further ado, let’s get straight to the code

* {
            margin: 0;
            padding: 0;
        }

        .container {
            margin:300px auto;
            height: 400px;
            width: 1146px;
            overflow: hidden;
        }

        /* .wrap */
        .wrap {
            position: relative;
            width:10000px;
            left: 0px;
            animation: animateImg ease 5s infinite normal;
        }

        /* Image size*/
        .wrap img {
            width: 1146px;
            float: left;
            height: 400px;
            display: block;
        }

        /* Animation */
        @keyframes animateImg {
            0% {
                left: 0px;
            }

            20% {
                left: -0px;
            }

            40% {
                left: -1146px;
            }

            60% {
                left: -2292px;
            }

            80% {
                left: -3438px;
            }

            100% {
                left: 0px;
            }
        }

The animation effect pixels are modified according to the size of your own picture

<div class="container">
        <div class="wrap">
            <img src="images/banner1.jpg"alt="" />
            <img src="images/banner2.jpg"alt="" />
            <img src="images/banner3.jpg"alt="" />
            <img src="images/banner4.jpg"alt="" />
        </div>

This is the end of this article about how to use pure CSS to achieve automatic rotation of carousel banners. For more information about how to use pure CSS to achieve automatic rotation of carousel banners, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Implementation steps for Docker deployment of SpringBoot applications

>>:  Detailed explanation of the use of Vue's new built-in components

Recommend

JavaScript to achieve product magnifying glass effect

This article shares the specific code of JavaScri...

Use of Linux watch command

1. Command Introduction The watch command execute...

HTML head tag detailed introduction

There are many tags and elements in the HTML head ...

XHTML Getting Started Tutorial: Simple Web Page Creation

Create your first web page in one minute: Let'...

Detailed tutorial on building Gitlab server on CentOS8.1

There is no need to say much about the difference...

Analysis of common usage examples of MySQL process functions

This article uses examples to illustrate the comm...

Docker and portainer configuration methods under Linux

1. Install and use Docer CE This article takes Ce...

When the interviewer asked the difference between char and varchar in mysql

Table of contents Difference between char and var...

Detailed explanation of jquery tag selector application example

This article example shares the specific code of ...

Detailed explanation of the execution process of MySQL query statements

Table of contents 1. Communication method between...

Detailed explanation of MySQL string concatenation function GROUP_CONCAT

In the previous article, I wrote a cross-table up...

Detailed explanation of the use of DockerHub image repository

Previously, the images we used were all pulled fr...