JS Growing Card Flip

CODEPEN:

Growing Card Flip

Github:https://github.com/furkangulsen98/HTML-CSS-JAVASCRIPT/tree/master/Growing%20Card%20Flip


HTML CODE:

 <div class="container">
        <div class="card">
            <div class="front">
                Front
            </div>
            <div class="back">
                Back
            </div>
        </div>
    </div>

CSS CODE:

body{
    background: #eee;
    padding: 0;
    margin: 0;
}
.container{
    font-family: Verdana;
    font-weight: bold;
    font-size: 75px;
    width: 400px;
    height: 250px;
    border-radius: 10px;
    perspective: 1400px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}
.card {
    position: relative;
    height: 100%;
    border-radius: 10px;
    width: 100%;
    transform-style: preserve-3d;
    transition-delay: 1s;
    transition: 1s ease-in-out;
    cursor: pointer;
}
.front, .back {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    text-align: center;
}
.back {
    color: #fff;
    background: #bc2828;
    transform: rotateY(180deg);
}
.front {
    position: absolute;
    top: 0;
    left: 0;
    background: #fff;
    color: #bc2828;
}
.card.active {
    transform: rotateY(180deg) rotateX(360deg) scale(2.5);

}

JS CODE:

   let card = document.querySelector(".card");
        card.addEventListener("click", function () {
            card.classList.toggle("active");
        });

One thought on “JS Growing Card Flip

Add yours

Leave a comment

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

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started