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

Mini Program natively implements left-slide drawer menu

Table of contents WXS Response Event Plan A Page ...

9 ways to show and hide CSS elements

In web page production, displaying and hiding ele...

border-radius method to add rounded borders to elements

border-radius:10px; /* All corners are rounded wi...

Several principles for website product design reference

The following analysis is about product design pr...

Basic reference types of JavaScript advanced programming

Table of contents 1. Date 2. RegExp 3. Original p...

Web Design TabIndex Element

TabIndex is to press the Tab key to sequentially o...

Example of removing json backslash in php

1. Remove backslashes through the "stripslas...

Zookeeper stand-alone environment and cluster environment construction

1. Single machine environment construction# 1.1 D...

mysql creates root users and ordinary users and modify and delete functions

Method 1: Use the SET PASSWORD command mysql -u r...

Slot arrangement and usage analysis in Vue

The operating environment of this tutorial: Windo...

Implementation of css transform page turning animation record

Page turning problem scenario B and C are on the ...