Next.js template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hover-image-card.module.css 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .container {
  2. display: flex;
  3. justify-content: center;
  4. margin-top: 30px;
  5. }
  6. .card {
  7. position: relative;
  8. width: 230px;
  9. height: 260px;
  10. margin: 0 5px;
  11. background-color: red;
  12. transition: 0.3s;
  13. overflow: hidden;
  14. cursor: pointer;
  15. }
  16. .card img {
  17. width: 100%;
  18. height: 100%;
  19. object-fit: cover;
  20. transition: 0.3s;
  21. }
  22. .card::after {
  23. content: '';
  24. position: absolute;
  25. left: 0;
  26. bottom: 0;
  27. width: 100%;
  28. height: 100%;
  29. opacity: 0;
  30. transition: 0.3s;
  31. background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1));
  32. }
  33. .content {
  34. position: absolute;
  35. bottom: 0;
  36. width: 100%;
  37. padding: 1rem;
  38. z-index: 1;
  39. color: #fff;
  40. transition: 0.3s;
  41. opacity: 0;
  42. }
  43. .btn {
  44. padding: 0.3rem 0.8rem;
  45. font-size: 0.6rem;
  46. border: none;
  47. cursor: pointer;
  48. outline: none;
  49. color: #fff;
  50. background: transparent;
  51. border: 2px solid #fff;
  52. }
  53. .content p {
  54. font-size: 0.6rem;
  55. margin: 0.5rem 0;
  56. }
  57. .card:hover {
  58. width: 350px;
  59. }
  60. .card:hover img {
  61. transform: scale(1.1);
  62. }
  63. .card:hover:after,
  64. .card:hover .content {
  65. opacity: 1;
  66. }