Check out this Pen I made!
Split an image into pieces using the mask property, then show it fully on hover. A single-element implementation using less than 10 CSS declarations.
img {
--g: 15px; /* control the gap */
width: 280px;
aspect-ratio: 1;
box-sizing: border-box;
--_g: var(--g)/calc(50% - var(--g)) calc(50% - var(--g))
no-repeat conic-gradient(#000 0 0);
mask:
left var(--_i,) top var(--_g),
bottom var(--_i,) left var(--_g),
top var(--_i,) right var(--_g),
right var(--_i,) bottom var(--_g);
transition: .3s linear;
}
img:hover {
--_i: var(--g);
padding: var(--g);
}
Top comments (0)