<section id="main">

    <nav>
      <div class="logo">
        <a href="#">OpenReplay</a>
      </div>
      <input class="menu-btn" type="checkbox" id="menu-btn" />
      <label class="menu-icon" for="menu-btn">
        <span class="nav-icon"></span>
      </label>

      <ul class="menu">
        <li><a href="#main">Home</a></li>
      </ul>

    </nav>
    <div class="scroller"></div>

    <div class="main-text">
      <p>Hello there,</p>
      <p>Welcome!</p>
      <p>This page has CSS scroll animations</p>
      <p>
        Keep scrolling to see how they work
      </p>
    </div>
  </section>


  <section id="sections">
    <div class="sections-text">
      <h2>Section</h2>
      <h3>These boxes fade in from the right and moves towards the left</h3>
    </div>
    <div class="container">
      <div class="box box-1">
        <h2>Box 1</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit perspiciatis accusantium nesciunt,
          officia sapiente natus!
        </p>
      </div>
      <div class="box box-2">
        <h2>Box 2</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit perspiciatis accusantium nesciunt,
          officia sapiente natus!
        </p>
      </div>
      <div class="box box-3">
        <h2>Box 3</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit perspiciatis accusantium nesciunt,
          officia sapiente natus!
        </p>
      </div>
    </div>
  </section>

  <section id="sections">
    <div class="sections-text">
      <h2>Section</h2>
      <h3>These boxes fade in from the right and moves towards the left</h3>
    </div>
    <div class="container">
      <div class="box box-1">
        <h2>Box 1</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit perspiciatis accusantium nesciunt,
          officia sapiente natus!
        </p>
      </div>
      <div class="box box-2">
        <h2>Box 2</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit perspiciatis accusantium nesciunt,
          officia sapiente natus!
        </p>
      </div>
      <div class="box box-3">
        <h2>Box 3</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit perspiciatis accusantium nesciunt,
          officia sapiente natus!
        </p>
      </div>
    </div>
  </section>
  <footer>
    <p>Built by Oscar Jite-Orimiono <i class="fas fa-smile-wink"></i></p>
  </footer>
@charset "utf=8";
@import url("https://fonts.googleapis.com/css2?family=Poppins&display=swap");

body {
  margin: 0px;
  padding: 0px;
  font-family: "Poppins", sans-serif;
  background: #22232e;
}
* {
  box-sizing: border-box;
  scroll-behavior: smooth;
}
ul {
  list-style: none;
}
a {
  text-decoration: none;
}
nav {
  display: inline-flex;
  justify-content: space-around;
  align-items: center;
  height: 60px;
  position: fixed;
  width: 100%;
  background-color: #004958;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding: 0px 5%;
  z-index: 1;
  animation: color-change linear;
  animation-timeline: scroll();
}
.logo a {
  font-weight: 700;
  color: #00c2cb;
  font-size: 2rem;
  letter-spacing: 0.5px;
}
nav ul {
  display: flex;
}
nav ul li a {
  height: 40px;
  line-height: 43px;
  margin: 10px;
  padding: 0px 30px;
  display: flex;
  font-size: 1rem;
  font-weight: 500;
  color: #00c2cb;
  transition: 0.1s;
}
nav ul li a:hover {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: #fff;
}

#main {
  width: 100%;
  height: 100vh;
  position: relative;
}
.main-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.main-text p:nth-child(1) {
  font-weight: 500;
  font-size: 27px;
  line-height: 20px;
}
.main-text p:nth-child(2) {
  font-size: 60px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.main-text p:nth-child(3) {
  font-size: 35px;
  line-height: 50px;
}
.main-text p:nth-child(4) {
  font-size: 20px;
  line-height: 20px;
}
.main-text p {
  color: #e0ffff;
  margin: 23px 0px 25px;
  line-height: 58px;
}
#sections {
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 30px 0px;
  flex-direction: column;
}
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 20px 0px;
}
.sections-text h2 {
  font-weight: 600;
  color: #00c2cb;
  font-size: 30px;
  line-height: 0px;
}
.sections-text h3 {
  font-weight: 500;
  color: #e0ffff;
}

.box {
  width: 300px;
  height: 320px;
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 7px;
  margin: 15px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background-color: #004958;
  transform: scale(0.8) translateX(200px);
  opacity: 0;
  transition: transform 0.3s linear, opacity 0.3s linear;
}
@supports (animation-timeline: view()) {
  .box {
    animation: reveal linear forwards;
    animation-timeline: view(block);
    animation-range: cover 0% entry 50%;
  }
}
.reveal {
  transform: scale(1) translateX(0);
  opacity: 1;
}
  @keyframes reveal {
    to {
      transform: scale(1) translateX(0);
      opacity: 1;
    }
  }
.box h2 {
  color: #00c2cb;
  font-size: 23px;
  line-height: 0px;
}
.box p {
  text-align: center;
  width: 230px;
  margin: 0px 0px 20px 0px;
  color: #e0ffff;
}

footer {
  display: flex;
  justify-content: space-around;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
  background: #004958;
}
footer p {
  margin: 15px 0px;
  color: #e0ffff;
  font-size: 0.9rem;
}
nav .menu-btn {
  display: none;
}

@keyframes scroller {
  to {
    transform: scale(1, 1);
  }
}
@keyframes color-change {
  to {
    background-color: #22232e;
  }
}
@media (max-width: 1000px) {
  * {
    box-sizing: border-box;
  }
  .main-text {
    top: 46%;
  }
}
@media (max-width: 1140px) {
  .main-text {
    margin: 10px;
  }
  .main-text h1 {
    font-size: 3rem;
  }
}
@media (max-width: 900px) {
  nav {
    justify-content: space-between;
    height: 65px;
    padding: 0px 30px;
  }
  .logo img {
    height: 35px;
  }
  .menu {
    display: none;
    position: absolute;
    top: 65px;
    left: 0px;
    background-color: #22232e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    padding: 0px;
    margin: 0px;
  }
  .menu li {
    width: 100%;
  }
  nav .menu li a {
    width: 100%;
    height: 40px;
    justify-content: center;
    align-items: center;
    margin: 0px;
    padding: 25px;
    border: 1px solid rgba(38, 38, 38, 0.03);
  }
  nav .menu-icon {
    cursor: pointer;
    float: right;
    padding: 28px 20px;
    position: relative;
    user-select: none;
  }
  nav .menu-icon .nav-icon {
    background-color: #00c2cb;
    display: block;
    height: 2px;
    position: relative;
    transition: background 0.2s ease-out;
    width: 18px;
  }
  nav .menu-icon .nav-icon::before,
  nav .menu-icon .nav-icon::after {
    background: #00c2cb;
    content: "";
    display: block;
    height: 100%;
    position: absolute;
    transition: all ease-out 0.2s;
    width: 100%;
  }
  nav .menu-icon .nav-icon:before {
    top: 5px;
  }
  nav .menu-icon,
  .nav-icon:after {
    top: -5px;
  }
  nav .menu-btn:checked ~ .menu-icon .nav-icon {
    background: transparent;
  }
  nav .menu-btn:checked ~ .menu-icon .nav-icon:before {
    transform: rotate(-45deg);
    top: 0;
  }
  nav .menu-btn:checked ~ .menu-icon .nav-icon:after {
    transform: rotate(45deg);
    top: 0;
  }
  nav .menu-btn {
    display: none;
  }
  nav .menu-btn:checked ~ .menu {
    display: block;
  }
}
@media (max-width: 720px) {
  .main-text {
    width: 70%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  footer {
    justify-content: center;
    padding: 10px 20px;
  }
  footer p {
    text-align: center;
  }
}
function reveal() {
      const boxes = document.querySelectorAll(".box");

      for (let i = 0; i < boxes.length; i++) {
        const windowHeight = window.innerHeight;
        const elementTop = boxes[i].getBoundingClientRect().top;
        const elementVisible = 150;

        if (elementTop < windowHeight - elementVisible) {
          boxes[i].classList.add("reveal");
        } else {
          boxes[i].classList.remove("reveal");
        }
      }
    }

    window.addEventListener("scroll", reveal);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.