Create a slider using Keyframes

We have created an animation using keyframes (slideshow), and on the main div (slideshow-wrapper), we have applied the animation with the following style: animation: slideshow 60s infinite;To add the code in SMT.

<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        /* default stylings */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        /* ----- container stylings: 
        -> centers the whole content of the page
        -> defines width and height for container ----- */
        .containerbanner {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            margin: auto;
            width:100%;
            height: auto;
            padding-top: 0px;
            padding-right: 0px;
            padding-bottom: 0px;
            padding-left: 0px
        }
        /* ----- end of container stylings ----- */  
        /* ----- slideshow stylings ----- */
        .slideshow {
            height: 100%;
            overflow: hidden; /* to hide slides in x-direction */
            position: relative;
        }
        /* wrapper which wraps all the slideshow images stylings */
        .slideshow-wrapper {
            display: flex;
            /* We give it width as 400% because we are making a 
            4 image carousel. If you want to make for example, 
            5 images carousel, then give width as 500%. */
            width: 700%;
            height: 100%;
            position: relative;
            /* you can change the animation settings from below */
            animation: slideshow 60s infinite;
        }
        /* define width and height for images*/
        .slide {
            width: 100%;
            height: 100%;
        }
        .slide-img {
            width: 100%;
            height: 100%;
            object-fit: cover; 
        }
        /* @keyframes are used to provide animations
        We make these settings for 4 image carousel.
        Make modification according to your needs. */
    @keyframes slideshow {
		0% { left: 0%; }
    20% { left: 0%; }
    25% { left: -125%; }
    35% { left: -125%; }
    40% { left: -250%; }
    50% { left: -250%; }
    55% { left: -350%; }
    60% { left: -350%; }
    70% { left: -470%; }
    75% { left: -470%; }
    80% { left: -590%; }
    88% { left: -590%; }
        }
    </style>
    <!--<title>Geeks For Geeks</title>-->
</head>
<body>
    <div class="containerbanner">
        <div class="slideshow">
                <div class="slideshow-wrapper">
                    <div class="slide">
                        <a href="https://www.oneweld.ca/ABRASIVES?display=table" target="_blank">
                        <img class="bannerImage" src="../SSP%20Applications/One%20Weld/SCA-OneWeld-Dev-Kilimanjaro/img/Image-Slider/upadted-banner%201.jpg"alt="banner image" style="width:100%"></a>
                    </div>
                    <div class="slide">
                            <a href="https://www.oneweld.ca/POLISHING?display=table" target="_blank">
                            <img class="bannerImage" src="../SSP%20Applications/One%20Weld/SCA-OneWeld-Dev-Kilimanjaro/img/Image-Slider/upadted-banner%202.jpg"alt="banner image" style="width:100%"></a>
                    </div>
                    <div class="slide">
                            <a href="https://www.oneweld.ca/CERAMICON-XT100-CUTTING-DISCS?quantity=1&custcol_matrix_options=53305" target="_blank">
                            <img class="bannerImage" src="../SSP%20Applications/One%20Weld/SCA-OneWeld-Dev-Kilimanjaro/img/Image-Slider/upadted-banner%203.jpg"alt="banner image" style="width:100%"></a>
                    </div>
                    <div class="slide">
                            <a href="https://www.oneweld.ca/" target="_blank">
                            <img class="bannerImage" src="../SSP%20Applications/One%20Weld/SCA-OneWeld-Dev-Kilimanjaro/img/Image-Slider/upadted-banner%204.jpg"alt="banner image" style="width:100%"></a>
                    </div>
                    <div class="slide">
                            <a href="https://www.oneweld.ca/WELDING?display=table" target="_blank">
                            <img class="bannerImage" src="../SSP%20Applications/One%20Weld/SCA-OneWeld-Dev-Kilimanjaro/img/Image-Slider/upadted-banner%205.jpg"alt="banner image" style="width:100%"></a>
                    </div>
                    <div class="slide">
                            <a href="https://www.oneweld.ca/WELDING?display=table" target="_blank">
                            <img class="bannerImage" src="../SSP%20Applications/One%20Weld/SCA-OneWeld-Dev-Kilimanjaro/img/Image-Slider/upadted-banner%206.jpg"alt="banner image" style="width:100%"></a>
                    </div>
                </div>
            </div>
        </div>
        <script>
    </script>
</body>
</html>

Leave a comment

Your email address will not be published. Required fields are marked *