Advertisement
Oscarobians

Animated Card Hover CSS

Apr 12th, 2024 (edited)
685
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.88 KB | None | 1 0
  1. /*
  2. Tutorial video: https://youtu.be/gyxRnOGIKqE
  3. Replace .blog-wrapper and .blog-card with the css class of your card container and your post card respectively
  4. */
  5.  
  6. .blog-wrapper::before {
  7.   content: "";
  8.   background-color: #222;
  9.   position: absolute;
  10.   width: calc(100% / 3);
  11.   height:100%;
  12.   z-index: -1;
  13.   translate: 0 0;
  14.   opacity: 0;
  15.   border-radius: 8px;
  16.   transition: translate 200ms;
  17. }
  18. .blog-wrapper:has(.blog-card:nth-child(1):hover)::before,.blog-wrapper:has(.blog-card:nth-child(1):focus-within)::before {
  19.   translate: 0 0;
  20.   opacity: 1;
  21. }
  22. .blog-wrapper:has(.blog-card:nth-child(2):hover)::before,.blog-wrapper:has(.blog-card:nth-child(2):focus-within)::before {
  23.   translate: 100% 0;
  24.   opacity: 1;
  25. }
  26. .blog-wrapper:has(.blog-card:nth-child(3):hover)::before,.blog-wrapper:has(.blog-card:nth-child(3):focus-within)::before {
  27.   translate: 200% 0;
  28.   opacity: 1;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement