{
  "id": "image-swap-hover",
  "name": "Image Swap on Hover",
  "category": "effects",
  "tags": [
    "product image",
    "second image",
    "hover swap",
    "ecommerce",
    "crossfade",
    "shop"
  ],
  "description": "A shop thumbnail that crossfades to a second product photo on hover, like most online stores do.",
  "url": "https://copy-css.com/snippets/image-swap-hover",
  "markdown": "https://copy-css.com/snippets/image-swap-hover.md",
  "html": "<a class=\"img-swap\" href=\"#\">\n  <img src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' fill='%23e0e7ff'/%3E%3Crect x='12' y='14' width='16' height='18' rx='2' fill='%236366f1'/%3E%3Cpath d='M16 15v-3a4 4 0 0 1 8 0v3' fill='none' stroke='%234338ca' stroke-width='1.6'/%3E%3C/svg%3E\" alt=\"Canvas tote bag, front\" width=\"200\" height=\"200\">\n  <img src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' fill='%23fde68a'/%3E%3Ccircle cx='20' cy='14' r='5' fill='%23b45309'/%3E%3Cpath d='M12 40c0-10 3-16 8-16s8 6 8 16z' fill='%2392400e'/%3E%3Crect x='22' y='26' width='11' height='12' rx='1.5' fill='%236366f1'/%3E%3Cpath d='M25 27v-2a2.5 2.5 0 0 1 5 0v2' fill='none' stroke='%234338ca' stroke-width='1.2'/%3E%3C/svg%3E\" alt=\"\" width=\"200\" height=\"200\">\n</a>",
  "css": ".img-swap {\n  display: grid;\n  width: 200px;\n  overflow: hidden;\n  border-radius: 14px;\n}\n\n.img-swap img {\n  grid-area: 1 / 1;\n  display: block;\n  width: 100%;\n  height: auto;\n  transition: opacity 0.4s ease, transform 0.6s ease;\n}\n\n.img-swap img + img {\n  opacity: 0;\n}\n\n.img-swap:hover img + img,\n.img-swap:focus-visible img + img {\n  opacity: 1;\n  transform: scale(1.04);\n}\n\n.img-swap:focus-visible {\n  outline: 3px solid #1c1917;\n  outline-offset: 3px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .img-swap img {\n    transition: none;\n  }\n}",
  "features": [
    "transitions",
    "transforms",
    "CSS Grid",
    "keyboard focus styles",
    "reduced-motion support"
  ],
  "customProperties": []
}
