Expanding Frame

An outer border expands outward from the image on hover/focus, growing to enclose it.

Expanding Frame demo

Hover or focus the image to see the effect.

HTML

description

CSS

.hover-effect.expanding-frame{
  position: relative;
  display: block;
}
.hover-effect.expanding-frame::before{
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid #10b981;
  border-radius: 8px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
.hover-effect.expanding-frame:hover::before,
.hover-effect.expanding-frame:focus-visible::before{
  opacity: 1;
  transform: scale(1);
}

The ::before animates opacity: 0 -> 1 and transform: scale(0.8) -> scale(1) on hover/focus, growing an outer frame to enclose the image. Select the code and copy with Ctrl+C or ⌘C.