How To Make Animation Profile Card Using CSS And Bootstrap Part-2

admin_img Posted By Bajarangi soft , Posted On 28-01-2021

We made an Animated Profile Card with Hover Animation using HTML CSS & JavaScript. Earlier I have shared a blog about how to create Responsive Profile Cards using only HTML & CSS.

How To Make Animation Profile Card Using CSS And Bootstrap Part-2

Step 1:Create css file like style.css.  
 

@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;1,100;1,300&family=Slabo+27px&display=swap");

*::after,
*::before {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Roboto", sans-serif;
    font-style: normal;
}

a,
a:hover,
a:focus,
a:active,
a:link {
    outline: none;
    text-decoration: none;
    color: #000;
}

.bs-card {
    position: relative;
    padding: 100px 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-wrap: wrap;
}
.bs-card .card {
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    width: 300px;
    height: 300px;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    min-width: 0;
    background: no-repeat;
    background-clip: border-box;
    box-shadow: none;
    border-radius: 0;
    border: 0;
    -webkit-transition: all 0.4s ease;
    -moz-transition: all 0.4s ease;
    -o-transition: all 0.4s ease;
    transition: all 0.4s ease;
    margin: 25px 0;
}

.bs-card .card .card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    z-index: 2;
}

.bs-card .card:hover .card-img {
    transform: translate(0, -35px);
}

.bs-card .card .card-img img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    z-index: 2;
    object-fit: cover;
}

.bs-card .card .card-body {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    padding: 0;
    z-index: 1;
    align-items: flex-end;
    justify-content: center;
    box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.2);
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

.bs-card .card:hover .card-body {
    transform: translate(0, 35px);
}


.bs-card .card .card-body .card-title {
    margin-bottom: 0;
}

.bs-card .card .card-body .card-title h5 {
    text-transform: uppercase;
    font-weight: 400;
    line-height: 5px;
}

@media only screen and (min-width: 768px) {
    .bs-card .card:hover .card-img  {
        transform: translate(35px, -35px) !important;
    }

    .bs-card .card:hover .card-body {
        transform: translate(-35px, 35px) !important;
    }
}

Step 2:Create html file like index.html and import style.css in it.
 
<!DOCTYPE html>
<html lang="en">
    <head>
        <!-- Required meta tags -->
        <title>card hover</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <link rel="stylesheet" type="text/css" href="css/style.css" />

    </head>
    <body>
        <!-- container -->
        <div class="container">
            <section class="bs-card">
                <div class="card">
                    <div class="card-img">
                        <img src="images/card/image-1.png" alt="Not Images" />
                    </div>
                    <div class="card-body">
                        <div class="card-title">
                            <h5>Kevin Carlsen</h5>
                            <p>Senior Front-end Developer</p>
                        </div>
                    </div>
                </div>

                <div class="card">
                    <div class="card-img">
                        <img src="images/card/image-2.png" alt="Not Images" />
                    </div>
                    <div class="card-body">
                        <div class="card-title">
                            <h5>Kevin Carlsen</h5>
                            <p>Senior Front-end Developer</p>
                        </div>
                    </div>
                </div>

                <div class="card">
                    <div class="card-img">
                        <img src="images/card/image-3.png" alt="Not Images" />
                    </div>
                    <div class="card-body">
                        <div class="card-title">
                            <h5>Kevin Carlsen</h5>
                            <p>Senior Front-end Developer</p>
                        </div>
                    </div>
                </div>
            </section>
        </div>
        <!-- container end -->

        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    </body>
</html>

Related Post