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.
*{
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;
}
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.
Post a Comment
Thank you
Learning robo team