Skip to content

CSS Card Animation


HTML CODE:

<!DOCTYPE html>
<html>
<head>
    <title>page</title>
    <link rel="stylesheet" type="text/css" href="2.page.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
</head>
<body>

    <div class="box">
        <div class="card"></div>
        <div class="card"></div>
        <div class="card"></div>
        <div class="card"></div>
        <div class="card"></div>
        <div class="card"></div>
        <div class="card"></div>
    </div>

</body>
</html>

CSS CODE:

body{
    margin: 0;
    padding: 0;
    background: #262626
}
.box{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 320px;
    height: 450px;
}
.box .card{
    position: absolute;
    top: 0;
    left: 0;
    width:100%;
    height: 100%;
    background: url(https://www.falderyasi.com/medya/iskambil/maca-kiz-iskambil-karti-www.falderyasi.com.png);
    background-position: center;
    background-size: cover;
    box-shadow: 0 2px 15px rgba(0,0,0,.5);
    transition: .5s;
    transform-origin: bottom;
    border-radius: 5px;
}
.box .card:nth-child(1){
    transform: translate(0px,0px);
}
.box .card:nth-child(2){
    transform: translate(2px,2px);
}
.box .card:nth-child(3){
    transform: translate(4px,4px);
}
.box .card:nth-child(4){
    transform: translate(6px,6px);
}
.box .card:nth-child(5){
    transform: translate(8px,8px);
}
.box .card:nth-child(6){
    transform: translate(10px,10px);
}
.box .card:nth-child(7){
    transform: translate(12px,12px);
}
.box .card:nth-child(1){
    transform: translate(0px,0px);
}
.box:hover .card:nth-child(1){
    transform:rotate(-45deg) translate(0px,0px);
}
.box:hover .card:nth-child(2){
    transform:rotate(-30deg) translate(0px,0px);
}
.box:hover .card:nth-child(3){
    transform:rotate(-15deg) translate(0px,0px);
}
.box:hover .card:nth-child(4){
    transform:rotate(0deg) translate(0px,0px);
}
.box:hover .card:nth-child(5){
    transform:rotate(15deg) translate(0px,0px);
}
.box:hover .card:nth-child(6){
    transform:rotate(30deg) translate(0px,0px);
}
.box:hover .card:nth-child(7){
    transform:rotate(45deg) translate(0px,0px);
}
.box .card:hover{
    z-index: 1;
    box-shadow: 0 20px 50px rgba(0,0,0,0,.5)
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: