Published on

A Complete Guide To Make A Card With Hover Animation With Tailwind CSS

Card with hover animation

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of Card with hover animation ui component

A interesting way to bring some life to your card's

Why use Tailwind CSS to build a Card with hover animation ui component?

  • It can make the building process of Card with hover animation ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Card with hover animation component file.

The preview of Card with hover animation ui component

Free download of the Card with hover animation's source code

The source code of Card with hover animation ui component

<div class="grid grid-cols-2 gap-4">
    <div class="bg-blue-300 w-52 h-72 m-8 static rounded-lg ">
        <div class="bg-white w-52 h-72 -m-2 hover:m-0 absolute rounded-lg shadow-lg hover:shadow-2xl transition-all duration-150 ease-out hover:ease-in ">
            <h1 class="m-4 text-2xl font-bold">Wat is Lorem Ipsum?</h1>
            <hr class="m-4 rounded-2xl border-t-2">
            <p class="m-4 text-sm">Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak</p>
        </div>
    </div>
    <div class="bg-green-300 w-52 h-72 m-8 static rounded-lg ">
        <div class="bg-white w-52 h-72 hover:-m-2 absolute rounded-lg shadow-lg hover:shadow-2xl transition-all duration-150 ease-out hover:ease-in ">
            <h1 class="m-4 text-2xl font-bold">Wat is Lorem Ipsum?</h1>
            <hr class="m-4 rounded-2xl border-t-2">
            <p class="m-4 text-sm">Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak</p>
        </div>
    </div>
    <div class="bg-red-300 w-52 h-72 m-8 static rounded-lg ">
        <div class="bg-white w-52 h-72 hover:m-2 absolute rounded-lg shadow-lg hover:shadow-2xl transition-all duration-150 ease-out hover:ease-in ">
            <h1 class="m-4 text-2xl font-bold">Wat is Lorem Ipsum?</h1>
            <hr class="m-4 rounded-2xl border-t-2">
            <p class="m-4 text-sm">Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak</p>
        </div>
    </div>
    <div class="bg-yellow-300 w-52 h-72 m-8 static rounded-lg ">
        <div class="bg-white w-52 h-72 m-2 hover:m-0 absolute rounded-lg shadow-lg hover:shadow-2xl transition-all duration-150 ease-out hover:ease-in ">
            <h1 class="m-4 text-2xl font-bold">Wat is Lorem Ipsum?</h1>
            <hr class="m-4 rounded-2xl border-t-2">
            <p class="m-4 text-sm">Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak</p>
        </div>
    </div>

</div>

How to build a Card with hover animation with Tailwind CSS?

Install tailwind css of verion 3.0.18

Use the script html tag to import the script of Tailwind CSS of the version 3.0.18

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to build a Card with hover animation component

  • grid
  • grid-cols-2
  • gap-4
  • bg-blue-300
  • w-52
  • h-72
  • m-8
  • static
  • bg-white
  • -m-2
  • hover:m-0
  • absolute
  • m-4
  • text-2xl
  • border-t-2
  • text-sm
  • bg-green-300
  • hover:-m-2
  • bg-red-300
  • hover:m-2
  • bg-yellow-300
  • m-2

22 steps to build a Card with hover animation component with Tailwind CSS

  1. Use grid to create a grid container.

  2. Use grid to create a grid container.

  3. To specify the width between columns, you can use the gap-4 utilities.

  4. Control the background color of an element to blue-300 using the bg-blue-300 utilities.

  5. Use w-52 to set an element to a fixed width(13rem).

  6. Use h-72 to set an element to a fixed height(18rem).

  7. Control the margin on all sides of an element to 2rem using the m-8 utilities.

  8. Use static to position an element according to the normal flow of the document.

  9. Control the background color of an element to white using the bg-white utilities.

  10. Control the margin on all sides of an element to -0.5rem using the -m-2 utilities.

  11. Control the margin on all sides of an element to 0rem on hover using the hover:m-0 utilities.

  12. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  13. Control the margin on all sides of an element to 1rem using the m-4 utilities.

  14. Control the text color of an element to 2xl using the text-2xl utilities.

  15. Control the border color of an element to t-2 using the border-t-2 utilities.

  16. Control the text color of an element to sm using the text-sm utilities.

  17. Control the background color of an element to green-300 using the bg-green-300 utilities.

  18. Control the margin on all sides of an element to -0.5rem on hover using the hover:-m-2 utilities.

  19. Control the background color of an element to red-300 using the bg-red-300 utilities.

  20. Control the margin on all sides of an element to 0.5rem on hover using the hover:m-2 utilities.

  21. Control the background color of an element to yellow-300 using the bg-yellow-300 utilities.

  22. Control the margin on all sides of an element to 0.5rem using the m-2 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to build a Card with hover animation components, learn and follow along to implement your own components.