Hello, friends. In this blog, we will learn how to create animated CSS cards using HTML CSS. Card elements are a useful component of any website. We often see these elements in blog post feed, team section designs, etc. A card element consists of an image followed by a title, description, and a call-to-action button. If we can add CSS animation to the card design, it will look even more attractive. For this reason, we have implemented a nice hover animation with the card design. For a video demonstration, please watch the video below.
I hope you have watched the video demo above and have some idea about what the cards will look like after the coding. You see in the demo how three different boxes are arranged one after the other. When we will hover the cards, the div will expand. We will see the details about the image. You can use these CSS profile cards for your projects.
Each card contains two sides. Side1 is made for images and headers and, side2 is made for details about that image. When we hover over the first, the second side will expand and we will see the rest of the content. The image details are wrapped in a div element with a class name 'img-info'. The 'img-info' div element will contain a title, a paragraph, and a call-to-action button.
First, create a div element called 'card'. Inside that card, create two more div elements with a class name 'side'. Both 'side' div elements will have some common styles. Place a separate class name in each 'side' div element because these two div elements will have different styles. Place all card elements inside a 'Team' div element.
In the CSS part, we will style the body element first. We gave a particular font family and custom background color for the project. After that, I have set a fixed width of 1200px for the 'team' div element. I have also set a fixed width (380x250) for the 'side' div elements. I have implemented CSS transform property for the expanded animation on hover. Initially, the side2 div content will be behind the side2 content. I have given the side1 div a z-index value so that it remains top of the side2 element. At first, the transform value in the y-direction will be 150px. To get the vertical expand animation on hover, I have set the value to zero. The opacity of the side1 element will be 0.2 but, for the hover state, the value will be 1.
You May Also Like:
CSS Card Hover Effects [ Source Code ]:
To create the project, first create one HTML file with a .html extension and one CSS file with a .css extension. Remember to link the external CSS file into your HTML file. After that, please copy the codes from the below code boxes and paste them into your files. If the code doesn't work then, download the code from the download button provided below.
ADD HTML:
ADD CSS:
I hope you have successfully implemented the code. In this blog, we share front-end-related source code regularly. Please follow us on our social media profiles to stay connected with us. Please share the articles with like-minded people. Thank you for visiting the blog.
Post a Comment
Please do not enter any spam link in the comment box.