Card Design with Hover Animation using HTML & CSS

 Hi Dev,

I have some code to share with you please find as below:


Code HTML (create file name index.html)


<!DOCTYPE html>
<html lang="en" dir="ltr">
   <head>
      <meta charset="utf-8">
      <title>Profile UI Card Design</title>
      <link rel="stylesheet" href="styles.css">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
   </head>
   <body>
      <div class="container">
         <div class="card">
            <div class="img">
               <img src="1.jpg">
            </div>
            <div class="top-text">
               <div class="name">
                  Rachana Keo
               </div>
               <p>
                  Graphic Developer
               </p>
            </div>
            <div class="bottom-text">
               <div class="text">
                  Hi, I'm Rachana and I'm passionate about Graphic Design. I
                  love to create beautiful and unique designs that capture
                  people's attention. I believe that good design has the power
                  to change the world and I strive to make a positive impact
                  through my work.
               </div>
               <div class="btn">
                  <a href="#">Read more</a>
               </div>
            </div>
         </div>
         <div class="card">
            <div class="img">
               <img src="5.jpg">
            </div>
            <div class="top-text">
               <div class="name">
                  Sovanna Thea
               </div>
               <p>
                  Website Developer
               </p>
            </div>
            <div class="bottom-text">
               <div class="text">
                  Sovanna Thea, web developer and coffee aficionado. I'm a big
                  fan of all things web development, and I also love my coffee.
               </div>
               <div class="btn">
                  <a href="#">Read more</a>
               </div>
            </div>
         </div>
         <div class="card">
            <div class="img">
               <img src="4.jpg">
            </div>
            <div class="top-text">
               <div class="name">
                  Huot Kea
               </div>
               <p>
                  App Developer
               </p>
            </div>
            <div class="bottom-text">
               <div class="text">
                  Hi! I'm Huot Kea, an app developer. I create fun, useful apps
                  that help make people's lives a little bit easier. I'm always
                  looking for new ideas, so if you have an idea for an app, let
                  me know!
               </div>
               <div class="btn">
                  <a href="#">Read more</a>
               </div>
            </div>
         </div>
      </div>
   </body>
</html>

Code CSS (create file name styles.css)

@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

html,
body {
    height: 100%;
    display: grid;
    place-items: center;
    background: #f2f2f2;
    text-align: center;
}

.container {
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card {
    height: 280px;
    max-width: 350px;
    margin: 0 20px;
    background: white;
    transition: 0.4s;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

.card:hover {
    height: 470px;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
}

.card .img {
    height: 200px;
    width: 100%;
}

.card .img img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.card .top-text {
    padding: 5px;
}

.card .top-text .name {
    font-size: 25px;
    font-weight: 600;
    color: #202020;
}

.card .top-text p {
    font-size: 20px;
    font-weight: 600;
    color: #e74c3c;
    line-height: 20px;
}

.card .bottom-text {
    padding: 0 20px 10px 20px;
    margin-top: 5px;
    background: white;
    opacity: 0;
    visibility: hidden;
    transition: 0.1s;
}

.card:hover .bottom-text {
    opacity: 1;
    visibility: visible;
}

.card .bottom-text .text {
    text-align: justify;
}

.card .bottom-text .btn {
    margin: 10px 0;
    text-align: left;
}

.card .bottom-text .btn a {
    text-decoration: none;
    background: #e74c3c;
    color: #f2f2f2;
    padding: 5px 8px;
    border-radius: 3px;
    display: inline-flex;
    transition: 0.2s;
}

.card .bottom-text .btn a:hover {
    transform: scale(0.9);
}

@media screen and (max-width: 978px) {
    .container {
        flex-wrap: wrap;
        flex-direction: column;
    }

    .card {
        max-width: 700px;
        margin: 20px 0;
    }
}

I hope this code can help you with a better design.

Post a Comment

Previous Post Next Post