3D Image Gallery with Flip Animation using HTML & CSS

3D Image Gallery with Flip Animation using HTML & CSS

Hello developers, today in this blog, you'll learn to create a 3D Image Gallery with Flip Animation using HTML & CSS.

The Image Gallery is the place, where the collection of images gets stored. Those stored images can be viewed whenever we want to see them. The 3D image describes an image that provides the perception of depth. When 3D images are made interactive so that the users feel involved with the scene, the experience is called virtual reality.

In this blog (3D Image Gallery with Flip Animation), in a webpage, there is the main preview image at the center of the webpage, and there are four images at right side of the main preview image. On randomly clicking on the image, the particular image will be displayed as the main preview image. The main preview image will rotate in a 3 dimensional visualization and show the particular clicked iamge. You can add the images as many images you need. 3D flip animation is made by using CSS transform property.

The source code of this 3D Image Gallery with Flip Animation is given below, if you want the source code of this program, you can copy it. You can use this 3D Image Gallery with Flip Animation with your creativity and can take this project to the next level.

3D Image Gallery with Flip Animation [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" dir="ltr"> <head> <meta charset="utf-8"> <title>3D Image Gallery with Flip Animation || Learningrobo</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <div class="center"> <input type="radio" checked name="active" id="tab-1"> <input type="radio" name="active" id="tab-2"> <input type="radio" name="active" id="tab-3"> <input type="radio" name="active" id="tab-4"> <div class="sliders"> <label for="tab-1"><img src="https://cdn.pixabay.com/photo/2016/11/12/22/42/santa-claus-1819933__340.jpg"></label> <label for="tab-2"><img src="https://cdn.pixabay.com/photo/2019/12/11/18/06/snowman-4688913__340.jpg"></label> <label for="tab-3"><img src="https://cdn.pixabay.com/photo/2012/04/13/01/23/moon-31665__340.png"></label> <label for="tab-4"><img src="https://cdn.pixabay.com/photo/2020/11/19/14/43/christmas-tree-5758765__340.jpg"></label> </div> <div class="img-card"> <img src="https://cdn.pixabay.com/photo/2016/11/12/22/42/santa-claus-1819933__340.jpg"> <img src="https://cdn.pixabay.com/photo/2019/12/11/18/06/snowman-4688913__340.jpg"> <img src="https://cdn.pixabay.com/photo/2012/04/13/01/23/moon-31665__340.png"> <img src="https://cdn.pixabay.com/photo/2020/11/19/14/43/christmas-tree-5758765__340.jpg"> </div> </div> <div class="credit">Made with<span style="color:tomato;"> ❤ </span>by<a href="https://www.learningrobo.com/"> Learning Robo</a></div> </div> </body> </html>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body{
  display: flex;
  height: 100vh;
  text-align: center;
  align-items: center;
  justify-content: center;
  font-family: Verdana, sans-serif; margin:0;
  background: #f2709c;  
  background: -webkit-linear-gradient(to right, #ff9472, #f2709c);  
  background: linear-gradient(to right, #ff9472, #f2709c); 
}
.center{
  position: relative;
  width: 770px;
  left: -70px;
  perspective: 1200px;
}
.center .img-card{
  position: relative;
  height: 350px;
  width: 400px;
  transform-style: preserve-3d;
  transition: transform .5s ease-in;
}
.img-card img{
  position: absolute;
  height: 100%;
  width: 100%;
  object-fit: cover;
}
.img-card img:nth-child(1){
  transform: rotateX(-270deg) translateY(-175px);
  transform-origin: top left;
}
.img-card img:nth-child(2){
  transform: translateZ(175px);
}
.img-card img:nth-child(3){
  transform: rotateX(-90deg) translateY(175px);
  transform-origin: bottom center;
}
.img-card img:nth-child(4){
  transform: rotateX(-180deg) translateY(350px) translateZ(175px);
  transform-origin: bottom right;
}
#tab-1:checked ~ .img-card{
  transform: rotateX(-90deg);
}
#tab-2:checked ~ .img-card{
  transform: rotateX(0deg);
}
#tab-3:checked ~ .img-card{
  transform: rotateX(90deg);
}
#tab-4:checked ~ .img-card{
  transform: rotateX(180deg);
}
.sliders{
  position: absolute;
  display: block;
  right: 0;
  top: -30px;
}
.sliders label{
  height: 98px;
  width: 110px;
  display: flex;
  overflow: hidden;
  cursor: pointer;
  margin: 6px 0;
  border: 3px solid  #bdc3c7;
}
.sliders label:nth-child(1){
  margin-top: 0;
}
label img{
  height: 100%;
  width: 100%;
  object-fit: cover;
  opacity: .9;
}

input{
  display: none;
}
.credit a{
    text-decoration: none;
    font-weight: 800;
    color: #12192c;
}
.credit {
    text-align: center;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    color: #000;
    margin-top: 80px;
}
We hope you would like this 3D Image Gallery with Flip Animation using HTML & CSS.

Thank you for reading our blog. If you face any problem in creating this 3D Image Gallery with Flip Animation 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

إرسال تعليق

Thank you
Learning robo team

Post a Comment (0)

أحدث أقدم
Learning Robo says...
code copied
Welcome