Responsive Horizontal Image Slider using HTML & CSS


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

The Image Slider is also called Image Carousel or Slideshow. The Image Slider may be the convenient way to display the changing or sliding images one by one on your website. Image slider or slideshow commonly shows one large image at a time with a little scrap of text, at the bottom of the image. In the Image Slider, the images will slide one by one when the image is clicked, manually.

In this blog (Responsive Horizontal Image Slider), in a webpage, there is the main slider at the center of the webpage, and there are four images below the main slider. On randomly clicking on the image, the particular image will be displayed on the main slider. You can add the images as many images you need. CSS @media query property has been used to make the page responsive.

The source code of this Responsive Horizontal Image Slider is given below, if you want the source code of this program, you can copy it. You can use this Responsive Horizontal Image Slider with your creativity and can take this project to the next level.

Responsive Horizontal Image Slider [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> <head> <title>Responsive Horizontal Image Slider|| Learningrobo</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="section full-height over-hide px-4 px-sm-0"> <div class="container"> <div class="row full-height"> <div class="col-lg-10 col-xl-8 padding-tb"> <div class="section mx-auto slider-height-padding"> <input class="checkbox frst" type="radio" id="slide-1" name="slider" checked/> <label for="slide-1"></label> <input class="checkbox scnd" type="radio" name="slider" id="slider-2"/> <label for="slider-2"></label> <input class="checkbox thrd" type="radio" name="slider" id="slider-3"/> <label for="slider-3"></label> <input class="checkbox foth" type="radio" name="slider" id="slider-4"/> <label for="slider-4"></label> <ul> <li> <span>Learning Robo</span> </li> <li> <span>Learning Robo</span> </li> <li> <span>Learning Robo</span> </li> <li> <span>Learning Robo</span> </li> </ul> </div> </div> </div> </div> </div> <div class="credit">Made with <span style="color:white;font-size:20px;">❤</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 responsive and attractive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700,800,900');

body{
	font-family: 'Poppins', sans-serif;
	font-weight: 300;
	font-size: 15px;
	line-height: 1.7;
	background: #E44D26;  
  background: -webkit-linear-gradient(to right, #F16529, #E44D26);  
  background: linear-gradient(to right, #F16529, #E44D26);

}
a {
	cursor: pointer;
}
a:hover {
	text-decoration: none;
}

.section{
  position: relative;
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.full-height{
  min-height: 100vh;
}

.padding-tb{
  padding-top: 100px;
}
[type="radio"]:checked,
[type="radio"]:not(:checked){
  position: absolute;
  left: -9999px;
}
.checkbox:checked + label,
.checkbox:not(:checked) + label{
  position: relative;
  cursor: pointer;
  margin: 0 auto;
  text-align: center;
  margin-right: 6px;
  margin-left: 6px;
  display: inline-flex;
  width: 150px;
  height: 150px;
  scroll-behavior: smooth;
  border: 3px solid #bdc3c7;
  background-size: cover;
  background-position: center;
  box-sizing: border-box;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
  background-image: url('https://cdn.pixabay.com/photo/2021/12/10/13/59/star-6860582__480.jpg');
  
}
.checkbox.scnd + label{
  background-image: url('https://cdn.pixabay.com/photo/2016/12/04/21/22/snowman-1882635__340.jpg');
}
.checkbox.thrd + label{
  background-image: url('https://cdn.pixabay.com/photo/2017/12/20/16/49/christmas-3030279__340.jpg');
}
.checkbox.foth + label{
  background-image: url('https://cdn.pixabay.com/photo/2019/11/23/07/33/candles-4646451__340.jpg');
}
.slider-height-padding {
  padding-top: 440px;
}
ul {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  z-index: 100;
  padding: 0;
  margin: 0;
  list-style: none;
}
ul li {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: block;
  z-index: 100;
  padding: 0;
  margin: 0;
  list-style: none;
  height: 400px;
  border: 5px solid #bdc3c7;
  background-size: cover;
  background-position: center;
  background-image: url('https://cdn.pixabay.com/photo/2021/12/10/13/59/star-6860582__480.jpg');
  border-radius: 50%;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 2px;
  line-height: 2.7;
  color: #E44D26;
  writing-mode: vertical-rl;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 8px 25px 0 rgba(16,39,112,.1);
  -webkit-transition: all 0.5s ease;
  transition: all 0.5s ease;
}
ul li span {
  mix-blend-mode: difference;
}
ul li:nth-child(2) {
  background-image: url('https://cdn.pixabay.com/photo/2016/12/04/21/22/snowman-1882635__340.jpg');
}
ul li:nth-child(3) {
  background-image: url('https://cdn.pixabay.com/photo/2017/12/20/16/49/christmas-3030279__340.jpg');
}
ul li:nth-child(4) {
  background-image: url('https://cdn.pixabay.com/photo/2019/11/23/07/33/candles-4646451__340.jpg');
}

.checkbox.frst:checked ~ ul li:nth-child(1) {
  opacity: 1;
  pointer-events: auto;
  border-radius: 16px;
}
.checkbox.scnd:checked ~ ul li:nth-child(2) {
  opacity: 1;
  pointer-events: auto;
  border-radius: 16px;
}
.checkbox.thrd:checked ~ ul li:nth-child(3) {
  opacity: 1;
  pointer-events: auto;
  border-radius: 16px;
}
.checkbox.foth:checked ~ ul li:nth-child(4) {
  opacity: 1;
  pointer-events: auto;
  border-radius: 16px;
}
@media (max-width: 767px) {
  .slider-height-padding {
    padding-top: 340px;
  }
  ul li {
    height: 300px;
    font-size: 13px;
    letter-spacing: 1px;
  }
}

@media (max-width: 575px) {
  .slider-height-padding {
    padding-top: 240px;
  }
  ul li {
    height: 200px;
  }
}
.credit a{
    text-decoration: none;
    font-weight: 800;
    color: #fff;
}
.credit {
    text-align: center;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    color: #000;
}
We hope you would like this Responsive Horizontal Image Slider using HTML & CSS.

Thank you for reading our blog. If you face any problem in creating this Responsive Horizontal 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