Hello, glad you are here. I am kunaal and today we will see how to make an awesome 3d card hover effect. You can see demo below.
Demo
Video Tutorial -
If you find this article hard or for better explanation. You can watch video tutorial.
If you like the video tutorial. Please consider subscribing my youtube channel.
Let's code
Inside HTML file under <body>
tag write
<div class="card">
<div class="card-img"></div>
<div class="card-body">
<span class="bg"></span>
<span class="bg"></span>
<span class="bg"></span>
<div class="content">
<h2 class="title">card 01</h2>
<p class="para">Lorem ipsum dolor sit amet consectetur adipisicing elit. Non aperiam fugiat eos odit numquam vitae facere dolore id libero sit!</p>
</div>
</div>
</div>
After that we only have to add CSS
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'roboto', sans-serif;
background: rgb(49, 162, 255);
perspective: 1000px;
}
.card{
width: 300px;
height: 450px;
position: relative;
transform-style: preserve-3d;
transition: 1s;
}
.card-img{
position: relative;
width: 100%;
height: 100%;
background: url(img.jpg);
background-size: cover;
border-radius: 20px;
transform: translateZ(40px);
}
.card-body{
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, -40px) rotateY(180deg);
width: 85%;
height: 87%;
border-radius: 20px;
overflow: hidden;
border: 5px solid #fff;
}
.card:hover{
transform: rotateY(180deg);
}
.card-body .bg{
position: absolute;
background: #fff;
border-radius: 100px;
width: 0%;
transition: .5s;
}
.card-body .bg:nth-child(1){
height: 25%;
transform-origin: left;
top: 0;
left: -30%;
transform: rotate(-10deg);
}
.card-body .bg:nth-child(2){
height: 50%;
transform-origin: right;
top: 5%;
right: -30%;
transform: rotate(-10deg);
}
.card-body .bg:nth-child(3){
height: 50%;
transform-origin: left;
top: 70%;
left: -30%;
transform: rotate(-10deg);
}
.card:hover .card-body .bg{
width: 200%;
transition-delay: 1s;
}
.card:hover .card-body .bg:nth-child(2){
transition-delay: 1.5s;
}
.card:hover .card-body .bg:nth-child(3){
transition-delay: 2s;
}
.content{
position: relative;
opacity: 0;
transition: .5s;
padding: 40px 10px;
text-align: center;
}
.title{
font-size: 60px;
margin-bottom: 20px;
color: #292929;
text-transform: uppercase;
}
.card:hover .content{
opacity: 1;
transition-delay: 2.5s;
}
I hope you understood everything. If you have any doubt or you find any mistake that I made or you have any suggestion feel free to ask me in comment.
If you are interested in programming and want to know how I a 15yr old teen do coding make these design. You can follow me on my Instagram. I am also planning to post my game development stuff on Instagram.
Top comments (7)
Nice but I think the 3 animated background spans gives it a bad UX. I simply don't think it is convenient for users. Great for practice and learning but not something I'd want in a real project.
Wow, nice work!!
Nice work!
This is really great
wow, this is great
Awesome !
Nice!