Gallery · 31 of 33

CRT Scanlines

Retro monitor effect with rolling sweep

HTML · CSS · No dependencies · MIT

HTML

<div class="crt-effect">
  <img src="https://picsum.photos/id/219/800/600" alt="CRT">
  <div class="crt-scanlines"></div>
  <div class="crt-sweep"></div>
</div>

CSS

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

.crt-effect img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.3s;
}

.crt-scanlines {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(to bottom,
    transparent 0 2px, rgba(0, 0, 0, 0.35) 2px 4px);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.crt-sweep {
  position: absolute;
  top: -20%; left: 0;
  width: 100%; height: 15%;
  background: linear-gradient(to bottom,
    transparent, rgba(255, 255, 255, 0.15), transparent);
  opacity: 0;
  pointer-events: none;
}

.crt-effect:hover .crt-scanlines { opacity: 1; }

.crt-effect:hover .crt-sweep {
  opacity: 1;
  animation: crt-roll 2.5s linear infinite;
}

.crt-effect:hover img {
  filter: contrast(1.15) saturate(1.3) brightness(1.05);
}

@keyframes crt-roll {
  0% { top: -20%; }
  100% { top: 120%; }
}