Responsive Automatic Image Slider using HTML & CSS

Responsive Automatic Image Slider using HTML & CSS

Hello developers, today in this blog, you'll learn how to create a Responsive Automatic Image Slider using HTML & CSS.


The Image Slider is also called Image Carousel or Slideshow. The Automatic Image Slider may be the convenient way to display the changing or sliding images one by one on your website. In this Automatic Image Slider, the images will automatically slide one by one, the users need not change the images manually.

To make the image slide automatically, the @keyframes property is used. The @keyframe rule specifies the image which gradually changes from the current image to the new image at a certain time.

In this Responsive Automatic Image Slider, five images move forward one by one and after all the images move forward it reverses all the images, and this repeats again and again. In this Responsive Automatic Image Slider, you can give the image as much you want.

The source code of this Responsive Automatic Image Slider using HTML & CSS is given below, and you can copy the source code of this program. You can use this code of Responsive Automatic Image Slider with your creativity and can take this card to the next level.

Responsive Automatic Image Slider using HTML & CSS [Source Code]

To make this website, you would like to make two files: an HTML file & a CSS file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Automatic image slider || Learning Robo</title> <link rel="stylesheet" href="style.css" /> </head> <body> <section class="auto-slider"> <div id="slider"> <figure> <img src="https://cdn.pixabay.com/photo/2021/08/25/09/42/attracting-6572957__340.png" alt="Image"> <img src="https://cdn.pixabay.com/photo/2021/08/25/12/45/phishing-6573326__340.png" alt="Image"> <img src="https://cdn.pixabay.com/photo/2021/08/25/11/30/plank-6573171__340.png" alt="Image"> <img src="https://cdn.pixabay.com/photo/2021/08/22/21/03/science-6566158__340.png" alt="Image"> <img src="https://cdn.pixabay.com/photo/2020/04/03/19/02/virus-4999857__340.png" alt="Image"> </figure> <div class="indicator"></div> </div> </section> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </body> </html>
CSS provides style to an HTML page. To make the page attractive and page responsive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


body {
    margin: 10px;
    font-family: 'Poppins', Arial, Helvetica, sans-serif;
    background-color: #2AF598;
    display: flex;
    flex-direction: column;
  }

.auto-slider{
    position: relative;
    box-sizing: content-box;
    display: inline-block;
    padding: 10px 10px 20px;
    background: #121;
    max-width: 720px;
    margin: 20px auto;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
 
}


div#slider { overflow: hidden; }
div#slider figure img { width: 20%; float: left;height:500px }
div#slider figure { 
  position: relative;
  width: 500%;
  margin: 0;
  left: 0;
  text-align: left;
  font-size: 0;
  animation: 45s sliding ease infinite; 
}

/* Slider indicator */
.indicator{
    width: 100%;
    max-width: 720px;
    height: 6px;
    background: #2AF598;
    position: absolute;
    bottom: 0;
    
    animation: indicating 9s ease infinite; 
    
}


@keyframes sliding{
    0%{left: 0%; }
    20%{left: -100%;}
    40%{left: -200%;}
    60%{left: -300%;}
    80%{left: -400%;}
    100%{left: 0%;}
}        

@keyframes indicating{
    from{
        left: -100%;
    }
    to{
        left: 0;
    }
}  
.credit{
    text-align: center;
    color: #000;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

.credit a{
    text-decoration: none;
    color:#000;
    font-weight: bold;
}  
We hope you would like this Responsive Automatic Image Slider using HTML & CSS.

Thank you for reading our blog. If you face any problem in creating this Responsive Automatic Image Slider using HTML & CSS, then contact us or comment us. We’ll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

Post a Comment

Thank you
Learning robo team

Post a Comment (0)

Previous Post Next Post
Learning Robo says...
code copied
Welcome