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

              
                <div class="movie">
  <div class="bg"><img src="http://7wallpapers.net/wp-content/uploads/10_Wonder-Woman.jpg" alt="">
  </div>
  <div class="story">
    <div class="story-content">
      <h2>Wonder Woman</h2>
      <h4>Diana, princess of the Amazons, trained to be an unconquerable warrior. Raised on a sheltered island paradise, when a pilot crashes on their shores and tells of a massive conflict raging in the outside world, Diana leaves her home, convinced she can stop the threat. Fighting alongside man in a war to end all wars, Diana will discover her full powers and her true destiny.</h4>
    </div>
  </div>
  <div class="actor">
    <ul>
      <li>
        <h2>Director</h2>
        <h4>Patty Jenkins</h4>
      </li>
      <li>
        <h2>Writers</h2>
        <h4>Allan Heinberg, Zack Snyder</h4>
      </li>
      <li>
        <h2>Stars</h2>
        <h4>Gal Gadot, Chris Pine</h4>
      </li>
    </ul>
  </div>
</div>

<ul class="scroll-wrap">
  <li></li>
  <li></li>
  <li></li>
</ul>
              
            
!

CSS

              
                body {
  margin: 0;
}
ul,
li {
  margin: 0;
  padding: 0;
  list-style: none;
}
.scroll-wrap {
  position: relative;
}
.scroll-wrap li {
  height: 100vh;
}
.movie {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: #fff;
  background:#111;
}
.movie .bg {
  width: 100vw;
  height: 100vh;
  /* Center slide text vertically */
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}
.movie .bg img {
/*   height:100vh; */
  transition: 1s;
}
.movie.step-2 .bg img {
  transform: scale(0.9);
}
.movie.step-3 .bg img {
  transform: scale(0.8);
}
.story,
.actor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  text-align: center;
  opacity: 0;
  transition: 1s;
}
.story:before,
.actor:before {
  content: "";
  display: inline-block;
  height: 100%;
  vertical-align: bottom;
}
.story-content,
.actor ul {
  display: inline-block;
  text-align: left;
  margin-bottom: 10%;
  width: 600px;
  transform: scale(2);
  transition: 1s;
}
.actor ul{
  margin-bottom: 20%;
}
.actor ul li {
  display: inline-block;
  vertical-align: top;
}
.actor ul li + li {
  margin-left: 40px;
}
.movie.step-2 .story,
.movie.step-3 .story {
  opacity: 1;
}
.movie.step-2 .story-content {
  transform: scale(1);
}
.movie.step-3 .story-content {
  transform: scale(0.5);
}
.movie.step-3 .actor {
  opacity: 1;
}
.movie.step-3 .actor ul {
  transform: scale(1);
}

              
            
!

JS

              
                lasScrTop = 0;
opa = 1;
sca = 5;
$(window).scroll(function () {
  winTop = $(this).scrollTop();
  winMid = $(window).height() / 2 + winTop;
  winBot = $(window).height() + winTop;
  // scroll到li,執行動態
  $(".scroll-wrap li").each(function () {
    liHei = $(this).height();
    liOff = $(this).offset();
    liTop = liOff.top;
    liBot = liTop + liHei;
    if (liBot <= winMid || liTop >= winBot) {
      // li滑出視窗時移除 inView
      $(this).removeClass("inView");
    } else if (liTop <= winMid) {
      // li滑到中間時,加入 inView
      $(this).addClass("inView");
    }
    inViewEq = $(".inView").index() + 1;
    console.log(inViewEq);
    $(".movie")
      .attr("class", "")
      .addClass("movie step-" + inViewEq);
  });
  // 判斷scroll往上滑或往下滑
  if (winTop > lasScrTop) {
    // 往下滑
  } else {
    // 往上滑
  }
  lasScrTop = winTop;
});

              
            
!
999px

Console