Card Design with Hover Animation using HTML & CSS

Card Design with Hover Animation using HTML & CSS

Hello developers, today in this blog, you'll learn how to create a Card Design with Hover Animation using HTML & CSS.

A card design is a UI design pattern that groups related information in a flexible-size container visually resembling a playing card. A card contains information about something or someone. A card consists of images and text.

In this program (Card Design with Hover Animation) on the webpage, three cards contain an image. There is an information part below the images respectively. If you hover over the image, the information container slides up and shows up the complete information part that overlays over half of the mage. CSS animation is used for the sliding up of the content. CSS border-radius property has been used for the information container. The information content of the card contains the profile picture of the person, their name, picture name, and the description of the content.

The source code of this Card Design with Hover Animation using HTML & CSS is given below, if you want the source code of this program, you can copy it. You can use this code of Card Design with Hover Animation with your creativity and can take this table to the next level.

Card Design with Hover Animation using HTML & CSS [Source Code]

To make this website, you would like to make two files: an HTML file & a CSS file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<!DOCTYPE html> <html> <head> <title>Card Design with Hover Animation || Learningrobo</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Art Gallery</h1> <ul class="cards"> <li> <a href="" class="card"> <img src="https://cdn.pixabay.com/photo/2017/08/10/12/54/bird-2622395__340.jpg" class="card__image" alt="" /> <div class="card__overlay"> <div class="card__header"> <img class="card__thumb" src="https://cdn.pixabay.com/photo/2018/11/13/21/43/instagram-3814049__340.png" alt="" /> <div class="card__header-text"> <h3 class="card__title">Charles Vincy</h3> <span class="card__status">Flying Bird</span> </div> </div> <p class="card__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada vulputate nisi in fermentum.</p> </div> </a> </li> <li> <a href="" class="card"> <img src="https://cdn.pixabay.com/photo/2017/09/05/23/07/dog-2719601__340.jpg" class="card__image" alt="" /> <div class="card__overlay"> <div class="card__header"> <img class="card__thumb" src="https://cdn.pixabay.com/photo/2018/11/13/21/43/instagram-3814049__340.png" alt="" /> <div class="card__header-text"> <h3 class="card__title">Swamy Nathan</h3> <span class="card__status">Watching Dog</span> </div> </div> <p class="card__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada vulputate nisi in fermentum.</p> </div> </a> </li> <li> <a href="" class="card"> <img src="https://cdn.pixabay.com/photo/2017/05/20/15/27/dolphin-2329165__340.jpg" class="card__image" alt="" /> <div class="card__overlay"> <div class="card__header"> <img class="card__thumb" src="https://cdn.pixabay.com/photo/2018/11/13/21/43/instagram-3814049__340.png" alt="" /> <div class="card__header-text"> <h3 class="card__title">Mohammad Hassina</h3> <span class="card__status">Dolphin</span> </div> </div> <p class="card__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada vulputate nisi in fermentum.</p> </div> </a> </li> </ul> <div class="credit">Made with <span style="color:tomato;font-size:20px;">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </body> </html>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and, remember that you have to make a file with a .css extension.


:root {
  --curve: 40;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'PT Sans Narrow', sans-serif;
  background-color: #000;
}
h1{
	text-align: center;
	color: #FFB6C1;
	font-size: 50px;
	letter-spacing: 2px;
	padding: 5px;
}
.cards {
  display: grid;
  justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 4rem 5vw;
  padding: 0;
  list-style-type: none;
}

.card {
  position: relative;
  display: block;
  height: 110%;  
  border-radius: calc(var(--curve) * 1px);
  overflow: hidden;
  text-decoration: none;
}

.card__image {      
  width: 100%;
  height: auto;
}

.card__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;      
  border-radius: calc(var(--curve) * 1px);    
  background-color: var(--surface-color);      
  transform: translateY(100%);
  transition: .2s ease-in-out;
}

.card:hover .card__overlay {
  transform: translateY(0);
}

.card__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2em;
  padding: .8em;
  border-radius: calc(var(--curve) * 1px) 0 0 0;    
  background-color: #FFB6C1;
  transform: translateY(-100%);
  transition: .2s ease-in-out;
}
.card:hover .card__header {
  transform: translateY(0);
}

.card__thumb {
  flex-shrink: 0;
  width: 50px;
  height: 50px;      
  border-radius: 50%;  
  border: 2px solid #000;    
}

.card__title {
  font-size: 1em;
  margin: 0 0 .3em;
}

.card__tagline {
  display: block;
  margin: 1em 0;
  font-family: "MockFlowFont";  
  font-size: .8em;  
}

.card__status {
  font-size: .8em;
}

.card__description {
  padding: 0 2em 2em;
  margin: 0;
  font-family: "MockFlowFont";   
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  background-color: #FFB6C1;
}    
.credit a{
  text-decoration: none;
  color: #FFB6C1;
  font-weight: 800;
}
.credit {
  position: fixed;
  color: #fff;
  left:40%;
  margin-top: 30px;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
}
We hope you would like this Card Design with Hover Animation using HTML & CSS.

Thank you for reading our blog. If you face any problem in creating this Card Design with Hover Animation using HTML & CSS then contact us or comment us. We’ll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

Post a Comment

Thank you
Learning robo team

Post a Comment (0)

Previous Post Next Post
Learning Robo says...
code copied
Welcome