Skip to content
Advertisements

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");
        });
Advertisements

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: