3D Image Slider using HTML & CSS (Code + Demo)

3D Image Slider using HTML & CSS

Do you want to create a 3D Image Slider using HTML and CSS?

If your answer is yes then this tutorial will help you completely. In this article, I have shown you how to create a 3D Image Slider. Image sliders are used in many places. Earlier I shared with you the tutorial for almost all design image sliders. It's a little different. 

In this case, by adding the images together at a certain angle, the shape of the 3D Image Slider has been given. Undoubtedly the kind of design will make your webpage more attractive. 

3D Cube Image Slider CSS

In this case, the images will continue to change automatically from time to time. Nine images have been used here. Each image is attached to the other at a 40-degree angle. Width of each image: 200px and some space between the images.

See the Pen Untitled by Ground Tutorial (@groundtutorial) on CodePen.


Arrangements have been made to automatically change these images using animations and @keyframes. Only HTML and CSS are used to create this CSS 3D Image Slider.

The images are first added by HTML and then by CSS the images are added at different angles and arranged in the form of a 3D Slider.

How to create a CSS 3D Image Slider

To create this 3D Image Slider, first, you need to create an HTML and CSS file. I have not shared any tutorial here. But before that, I have shared step by step tutorial of another 3D Image Slider HTML CSS of this kind.

Here I have given the necessary codes. You will copy those codes directly and add them to your file.

HTML Code (index.html)

The following codes are HTML codes. Copy these codes and add them to your HTML file.


<!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>Document</title>
  <!--CSS file-->
  <link rel="stylesheet" href="style.css">
</head>
<body>
<section id="slideshow">
  <div class="entire-content">
     <div class="content-carrousel">
        <figure class="shadow"><img src="https://i.pinimg.com/originals/2b/de/de/2bdede0647e3cdf75b44ea33723201d9.jpg"/></figure>
        <figure class="shadow"><img src="https://images6.alphacoders.com/462/thumb-1920-462371.jpg"/></figure>
        <figure class="shadow"><img src="https://wallpaperaccess.com/full/1154341.jpg"/></figure>
        <figure class="shadow"><img src="https://wallpaperaccess.com/full/6817.jpg"/></figure>
        <figure class="shadow"><img src="https://images.pexels.com/photos/54630/japanese-cherry-trees-flowers-spring-japanese-flowering-cherry-54630.jpeg?w=940&h=650&auto=compress&cs=tinysrgb"/></figure>
        <figure class="shadow"><img src="https://images5.alphacoders.com/343/thumb-1920-343645.jpg"/></figure>
        <figure class="shadow"><img src="https://www.pixelstalk.net/wp-content/uploads/images2/Nature-flowers-rose.jpg"/></figure>
        <figure class="shadow"><img src="https://wallpaper-mania.com/wp-content/uploads/2018/09/High_resolution_wallpaper_background_ID_77700291270.jpg"/></figure>
        <figure class="shadow"><img src="https://cdn.wallpapersafari.com/24/98/dwMtqD.jpg"/></figure>
     </div>
  </div>
</section>
</body>
</html>

CSS Code (style.css)

Now it's time to design the 3D Image Slider by CSS and activate the slider. To do this, copy the following code and add it to your CSS file.

/* Design the webpage */
* {
 margin: 0;
 padding: 0;
}

html, body {
 max-width: 100%;
 overflow-x: hidden;
 overflow-y: hidden;
 background-color: #5bccee;
}
/*Slider basic area*/
#slideshow {
 margin: 0 auto;
 background-color: #5bccee;
 box-sizing: border-box;
 padding-top: 50px;
 height: 600px;
 width: 100%;
}
/*slider area*/
.entire-content {
 margin: auto;
 position: relative;
 padding-top: 80px;
 width: 200px;
 perspective: 1000px;
}

.content-carrousel {
 width: 100%;
 position: absolute;
 float: right;
 animation: rotar 15s infinite linear;
 transform-style: preserve-3d;
}
/*slider hover effect*/
.content-carrousel:hover {
 animation-play-state: paused;
 cursor: pointer;
}
/* images*/
.content-carrousel figure {
 width: 100%;
 overflow: hidden;
 position: absolute;
 height: 120px;
 border: 1px solid #3b444b;
}
/* make it 3d */
.content-carrousel figure:nth-child(1) {
transform: rotateY(0deg) translateZ(300px);
}
.content-carrousel figure:nth-child(2) {
transform: rotateY(40deg) translateZ(300px);
}
.content-carrousel figure:nth-child(3) {
transform: rotateY(80deg) translateZ(300px);
}
.content-carrousel figure:nth-child(4) {
transform: rotateY(120deg) translateZ(300px);
}
.content-carrousel figure:nth-child(5) {
transform: rotateY(160deg) translateZ(300px);
}
.content-carrousel figure:nth-child(6) {
transform: rotateY(200deg) translateZ(300px);
}
.content-carrousel figure:nth-child(7) {
transform: rotateY(240deg) translateZ(300px);
}
.content-carrousel figure:nth-child(8) {
transform: rotateY(280deg) translateZ(300px);
}
.content-carrousel figure:nth-child(9) {
transform: rotateY(320deg) translateZ(300px);
}
.content-carrousel figure:nth-child(10) {
transform: rotateY(360deg) translateZ(300px);
}
/* image shadow*/
.shadow {
  position: absolute;
  box-shadow: 0px 0px 20px 0px #000;
  border-radius: 1px;
}
/*slider image*/
.content-carrousel img {
 width: 100%;
 height: 100%;
 image-rendering: auto;
 transition: all 300ms;
}
/*images hover effect*/
.content-carrousel img:hover {
 transform: scale(1.2);
 transition: all 300ms;
}
/* rotate animation*/
@keyframes rotar {
from {
  transform: rotateY(0deg);
} to {
  transform: rotateY(360deg);
}
}

If you have difficulty copying the above code, use the download button below. All the codes in this 3D Image Slider are linked together. Hopefully, you have been able to create this CSS 3D Image Slider using the above code.




Comments

Popular posts from this blog

Simple Day Night Toggle Button Using HTML and CSS

Splash Image Mask Using HTML and CSS (Free Code)

How To Limit Character In Input Field using JavaScript