Scroll · 07 of 34

Rotate In

Content swings in with a small rotation that straightens out as it lands. A rotate plus translate combo that adds character without heavy motion.

HTML · CSS · JavaScript · No dependencies · MIT

HTML

<section class="rotate-in-section">
  <h2>Rotate In</h2>
</section>

CSS

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

.rotate-in-section h2 {
  font-size: 2.5rem;
  color: #f0f0f5;
  opacity: 0;
  transform: rotate(-12deg) scale(0.9);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.rotate-in-section.in-view h2 {
  opacity: 1;
  transform: rotate(0) scale(1);
}

JavaScript

var section = document.querySelector('.rotate-in-section');

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