Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <section class="box-hero">
  <div class="box-hero_copy">
    <h1 class="h1">Top #1 Real Estate Seller Agent in Miami Beach</h1>
    <p class="h4">
      Take advantage of experience — sell your home today for more
    </p>
    <div>
      <a href="#link" class="btn">Scroll to Begin</a>
    </div>

  </div>
  <div class="box-hero_img">

  </div>
  <div class="background"></div>
</section>

<section class="box-intro">
  <div class="box-intro_copy">
    <h2 class="h1">Lorem Ipsum best not make any more threats to your website</h2>
    <p class="h4">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit
    </p>
  </div>
</section>
<div class="spacer"></div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.box-hero {
  width: 100%;
  height: 100vh;
  position: relative;
  z-index: 5;
  visibility: visible;
  background: #000;
  transition: opacity 0.5s;
}
.box-hero_img {
  width: 100%;
  height: 100%;
  position: fixed !important;
  top: 0;
  z-index: 0;
  transition: opacity 0.5s;
  background-image: url("https://picsum.photos/1600/800/");
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.6;
}
.box-hero_copy {
  position: absolute;
  width: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  color: #fff;
  padding: 3rem 1rem;
  max-width: 960px;
  text-align: center;
}
.h1 {
  font-size: 56px;
}
.h4 {
  font-size: 20px;
}
.box-hero .background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  z-index: -1;
}
.btn {
  padding: 0.75rem;
  border-radius: 1000px;
  color: #000;
  background: lightgray;
  width: 140px;
  margin: auto;
  font-size: 1rem;
  display: block;
  text-decoration: none;
  margin-top: 2rem;
}

.box-intro {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #fff;
  width: 100%;
  height: 100vh;
  top: 0 !important;
  z-index: 4;
  background: rgba(0, 0, 0, 0.4);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.5s;
}

.box-intro_copy {
  max-width: 960px;
}

.spacer {
  width: 100%;
  height: 100vh;
  background: coral;
}

              
            
!

JS

              
                console.clear();

// gsap.to()... infinity and beyond!
// For more check out greensock.com
gsap.registerPlugin(ScrollTrigger);

const hero = document.querySelector(".box-hero");
const boxIntro = document.querySelector(".box-intro");
const introText = document.querySelector(".box-intro_copy");

const tl = gsap.timeline();

tl.to(hero, {
  autoAlpha: 0,
  duration: 1 // Adjust the duration for the fade-out effect
});

tl.fromTo(
  boxIntro,
  {
    autoAlpha: 0,
    background: "transparent"
  },
  {
    autoAlpha: 1,
    background: "#43474c",
    duration: 1 // Adjust the duration for the fade-in effect
  },
  "-=1.5"
); // Delay the fade-in effect slightly

ScrollTrigger.create({
  animation: tl,
  trigger: ".box-intro",
  start: "top center",
  end: "top top",
  scrub: true,
  onUpdate: (self) => {
    // Adjust the autoAlpha of section 1 based on the scroll position
    hero.style.visibility = self.progress === 0.5 ? "hidden" : "visible";
    hero.style.zIndex = self.progress === 1 ? "-5" : "5";

    // Adjust the autoAlpha of section 2 based on the scroll position
    boxIntro.style.opacity = self.progress === 0.5 ? 0 : 1;
    boxIntro.style.zIndex = self.progress === 1 ? "4" : "4";
  }
});

gsap.set(introText, { opacity: 0, ease: "power1.out" });

// ScrollTrigger.create({
//   trigger: boxIntro,
//   start: "top top",
//   endTrigger: introText,
//   end: "+=50%",
//   markers: true,
//   pin: true,
//   pinSpacing: false,
//   onEnter: () => {
//     gsap.to(introText, { opacity: 1, duration: 0.5 });
//   },
//   onLeaveBack: () => {
//     gsap.to(introText, { opacity: 0, duration: 0.5 });
//   }
// });

              
            
!
999px

Console