Scroll · 09 of 34

Blur to Sharp

Content comes into focus as it enters view, starting blurred and transparent. A CSS filter blur that transitions to zero; keep the radius small for performance.

HTML · CSS · JavaScript · No dependencies · MIT

HTML

<section class="blur-sharp-section">
  <h2>Blur to Sharp</h2>
</section>

CSS

.blur-sharp-section {
  min-height: 35vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.blur-sharp-section h2 {
  font-size: 2.5rem;
  color: #f0f0f5;
  opacity: 0.6;
  filter: blur(12px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.blur-sharp-section.in-view h2 {
  opacity: 1;
  filter: blur(0);
}

JavaScript

var section = document.querySelector('.blur-sharp-section');

new IntersectionObserver(function (entries) {
  entries.forEach(function (entry) {
    entry.target.classList.toggle('in-view', entry.isIntersecting);
  });
}, { threshold: 0.25 }).observe(section);