Gallery · 14 of 33

Border Draw

Line traces inside edge

HTML · CSS · No dependencies · MIT

HTML

<div class="border-draw">
  <img src="https://picsum.photos/id/88/800/600" alt="Road">
  <div class="border-box"></div>
</div>

CSS

.border-draw {
  position: relative;
  width: 400px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
}

.border-draw img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.border-box {
  position: absolute;
  top: 1rem; left: 1rem; right: 1rem; bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.border-draw:hover .border-box {
  transform: scale(1);
  opacity: 1;
}

.border-draw:hover img {
  transform: scale(1.05);
}