CardsTutorials

3D Card Fold & Reveal

3D Card Fold & Reveal

3D Card Fold & Reveal

Before We Start to Create 3D Card Fold & Reveal

3D Card Fold & Reveal can be used to animate a section with images or any other media content and create user attractive UI components with cards.

So if you are a person who wishes to develop a website, you have to know how to create animations properly. Check out our tutorial and you can learn this techniques and use it on your web development. Below sections shows how to develop this animations.

How to create 3D Card Fold & Reveal? We are here to solve your problem. In this article we discuss how to create a hover effect animations. Before we start please read the below articles which easier you to understand the process, if you are new to development.

Step 1 – Add HTML

It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag as below.

<body>
<div class="cards">

            <div class="card">
                <div class="card__image-holder">
                    <img class="card__image" src="https://pixabay.com/get/gcc417a0d0f8077c08fc8467f28c14db296566d11f8a92d37c4c19c7d310eb9a6b6d37064a0668231f8ba5ccde671a04b_1280.jpg" alt="Image" />
                </div>
                <div class="card-title">
                    <a href="#" class="toggle-info btn">
                        <span class="left"></span>
                        <span class="right"></span>
                    </a>
                    <h2>
                        Title
                    </h2>
                </div>
                <div class="card-flap flap1">
                    <div class="card-description">
                        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                    </div>
                    <div class="card-flap flap2">
                        <div class="card-actions">
                            <a href="#" class="btn">Read more</a>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card">
                <div class="card__image-holder">
                    <img class="card__image" src="https://pixabay.com/get/gcc417a0d0f8077c08fc8467f28c14db296566d11f8a92d37c4c19c7d310eb9a6b6d37064a0668231f8ba5ccde671a04b_1280.jpg" alt="Image" />
                </div>
                <div class="card-title">
                    <a href="#" class="toggle-info btn">
                        <span class="left"></span>
                        <span class="right"></span>
                    </a>
                    <h2>
                        Title
                    </h2>
                </div>
                <div class="card-flap flap1">
                    <div class="card-description">
                        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                    </div>
                    <div class="card-flap flap2">
                        <div class="card-actions">
                            <a href="#" class="btn">Read more</a>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card">
                <div class="card__image-holder">
                    <img class="card__image" src="https://pixabay.com/get/gcc417a0d0f8077c08fc8467f28c14db296566d11f8a92d37c4c19c7d310eb9a6b6d37064a0668231f8ba5ccde671a04b_1280.jpg" alt="Image" />
                </div>
                <div class="card-title">
                    <a href="#" class="toggle-info btn">
                        <span class="left"></span>
                        <span class="right"></span>
                    </a>
                    <h2>
                        Title
                    </h2>
                </div>
                <div class="card-flap flap1">
                    <div class="card-description">
                        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                    </div>
                    <div class="card-flap flap2">
                        <div class="card-actions">
                            <a href="#" class="btn">Read more</a>
                        </div>
                    </div>
                </div>
            </div>

        </div>
</body>

Step 2 – Add CSS

Copy and paste below code in your HTML editor between <style></style> tag as below.

<style>
            @font-face {
                font-family: 'Source Sans Pro';
                font-style: normal;
                font-weight: 200;
                src: url(https://fonts.gstatic.com/s/sourcesanspro/v22/6xKydSBYKcSV-LCoeQqfX1RYOo3i94_wlxdr.ttf) format('truetype');
            }

            @font-face {
                font-family: 'Source Sans Pro';
                font-style: normal;
                font-weight: 300;
                src: url(https://fonts.gstatic.com/s/sourcesanspro/v22/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwlxdr.ttf) format('truetype');
            }

            @font-face {
                font-family: 'Source Sans Pro';
                font-style: normal;
                font-weight: 400;
                src: url(https://fonts.gstatic.com/s/sourcesanspro/v22/6xK3dSBYKcSV-LCoeQqfX1RYOo3qOK7g.ttf) format('truetype');
            }

            @font-face {
                font-family: 'Source Sans Pro';
                font-style: normal;
                font-weight: 600;
                src: url(https://fonts.gstatic.com/s/sourcesanspro/v22/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwlxdr.ttf) format('truetype');
            }

            @font-face {
                font-family: 'Source Sans Pro';
                font-style: normal;
                font-weight: 700;
                src: url(https://fonts.gstatic.com/s/sourcesanspro/v22/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlxdr.ttf) format('truetype');
            }

            @font-face {
                font-family: 'Source Sans Pro';
                font-style: normal;
                font-weight: 900;
                src: url(https://fonts.gstatic.com/s/sourcesanspro/v22/6xKydSBYKcSV-LCoeQqfX1RYOo3iu4nwlxdr.ttf) format('truetype');
            }

            body {
                background: #dce1df;
                color: #4f585e;
                font-family: 'Source Sans Pro', sans-serif;
                text-rendering: optimizeLegibility;
            }

            a.btn {
                background-color: #c0ca15;
                border-radius: 4px;
                box-shadow: 0 2px 0px 0 rgba(0, 0, 0, 0.25);
                color: #ffffff;
                display: inline-block;
                padding: 6px 30px 8px;
                position: relative;
                text-decoration: none;
                transition: all 0.1s 0s ease-out;
            }

            .no-touch a.btn:hover {
                background-color: #7a810e !important;
                box-shadow: 0px 8px 2px 0 rgba(0, 0, 0, 0.075);
                transform: translateY(-2px);
                transition: all 0.25s 0s ease-out;
            }

            .no-touch a.btn:active,
            a.btn:active {
                background-color: #7a810e;
                box-shadow: 0 1px 0px 0 rgba(255, 255, 255, 0.25);
                transform: translate3d(0, 1px, 0);
                transition: all 0.025s 0s ease-out;
            }

            div.cards {
                margin: 115px auto;
                max-width: 960px;
                text-align: center;
            }

            div.card {
                background: #ffffff;
                display: inline-block;
                margin: 8px;
                max-width: 300px;
                perspective: 1000;
                position: relative;
                text-align: left;
                transition: all 0.3s 0s ease-in;
                width: 300px;
                z-index: 1;
            }

            div.card img {
                max-width: 100%;
            }

            div.card .card__image-holder {
                background: rgba(0, 0, 0, 0.1);
                height: 0;
                padding-bottom: 64%;
            }

            div.card div.card-title {
                background: #ffffff;
                padding: 6px 15px 10px;
                position: relative;
                z-index: 0;
            }

            div.card div.card-title a.toggle-info {
                border-radius: 32px;
                height: 32px;
                padding: 0;
                position: absolute;
                right: 15px;
                top: 10px;
                width: 32px;
            }

            div.card div.card-title a.toggle-info span {
                background: #000;
                display: block;
                height: 2px;
                position: absolute;
                top: 16px;
                transition: all 0.15s 0s ease-out;
                width: 12px;
            }

            div.card div.card-title a.toggle-info span.left {
                right: 12px;
                transform: rotate(45deg);
            }

            div.card div.card-title a.toggle-info span.right {
                left: 13px;
                transform: rotate(-45deg);
            }

            div.card div.card-title h2 {
                font-size: 24px;
                font-weight: 700;
                letter-spacing: -0.05em;
                margin: 0;
                padding: 0;
            }

            div.card div.card-title h2 small {
                display: block;
                font-size: 18px;
                font-weight: 600;
                letter-spacing: -0.025em;
            }

            div.card div.card-description {
                padding: 0 15px 10px;
                position: relative;
                font-size: 14px;
            }

            div.card div.card-actions {
                box-shadow: 0 2px 0px 0 rgba(0, 0, 0, 0.075);
                padding: 10px 15px 20px;
                text-align: center;
            }

            div.card div.card-flap {
                background: #d9d9d9;
                position: absolute;
                width: 100%;
                transform-origin: top;
                transform: rotateX(-90deg);
            }

            div.card div.flap1 {
                transition: all 0.3s 0.3s ease-out;
                z-index: -1;
            }

            div.card div.flap2 {
                transition: all 0.3s 0s ease-out;
                z-index: -2;
            }

            div.cards.showing div.card {
                cursor: pointer;
                opacity: 0.6;
                transform: scale(0.88);
            }

            .no-touch div.cards.showing div.card:hover {
                opacity: 0.94;
                transform: scale(0.92);
            }

            div.card.show {
                opacity: 1 !important;
                transform: scale(1) !important;
            }

            div.card.show div.card-title a.toggle-info {
                background: #7a810e !important;
            }

            div.card.show div.card-title a.toggle-info span {
                top: 15px;
            }

            div.card.show div.card-title a.toggle-info span.left {
                right: 12px;
            }

            div.card.show div.card-title a.toggle-info span.right {
                left: 13px;
            }

            div.card.show div.card-flap {
                background: #ffffff;
                transform: rotateX(0deg);
            }

            div.card.show div.flap1 {
                transition: all 0.3s 0s ease-out;
            }

            div.card.show div.flap2 {
                transition: all 0.3s 0.2s ease-out;
            }
        </style>

At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.

Step 3 – Add JavaScript

Copy and paste below code in your HTML editor between <script></script> tag.

<script>
        $(document).ready(function() {
            var zindex = 10;

            $("div.card").click(function(e) {
                e.preventDefault();

                var isShowing = false;

                if ($(this).hasClass("show")) {
                    isShowing = true;
                }

                if ($("div.cards").hasClass("showing")) {
                    // a card is already in view
                    $("div.card.show").removeClass("show");

                    if (isShowing) {
                        // this card was showing - reset the grid
                        $("div.cards").removeClass("showing");
                    } else {
                        // this card isn't showing - get in with it
                        $(this).css({
                            zIndex: zindex
                        }).addClass("show");
                    }

                    zindex++;
                } else {
                    // no cards in view
                    $("div.cards").addClass("showing");
                    $(this).css({
                        zIndex: zindex
                    }).addClass("show");

                    zindex++;
                }
            });
        });
</script>

Video Tutorial

Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.


Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button