Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                  <!-- svg is defined here because of a Safari bug with <use> -->
  <svg>
    <defs>
      <g id="p">
        <path opacity=".2" d="M0 2h252s-3.3 40.7-2.7 128.3C249 216 252 272 252 272s-88-2-124.3-2C91.3 270 0 272 0 272V0z"/><path fill="#f4f3f1" d="M0 0h248v270H0z"/><path fill="#4f5150" d="M8 10h233v203H8z"/>
      </g>
      <g id="polaroid">
        <use xlink:href="#p" transform="rotate(15)" x="175" y="50"/>
        <use xlink:href="#p" transform="rotate(-5)" x="5" y="25"/>
      </g>
    </defs>
  </svg>

  <div class="demo__info">
    Pure CSS parallax scrolling with navigation and CSS scrolling with scroll-behavior: smooth by Keith Clark. Please read the <a href="https://keithclark.co.uk/articles/practical-css-parallax/">blog post</a> for more information.
  </div>

  <nav>
    <ul class="nav">
      <li><a href="#slide-1">Slide 1</a></li>
      <li><a href="#slide-2">Slide 2</a></li>
      <li><a href="#slide-3">Slide 3</a></li>
      <li><a href="#slide-4">Slide 4</a></li>
      <li><a href="#slide-5">Slide 5</a></li>
      <li><a href="#slide-6">Slide 6</a></li>
    </ul>
  </nav>

  <div class="slides">
    <div class="slide" id="slide-1">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <div class="slide__text">
          <h1 id="slide-1-title">Pure CSS Parallax</h1>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
        </div>
        <div class="slide__image">
          <svg viewBox="0 0 400 425" width="400" height="425"><use xlink:href="#polaroid"/></svg>
        </div>
      </div>
    </div>

    <div class="slide" id="slide-2">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <div class="slide__text">
          <h1 id="slide-2-title">Slide 2 title</h1>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
        </div>
        <div class="slide__image">
          <svg viewBox="0 0 400 425" width="400" height="425"><use xlink:href="#polaroid"/></svg>
        </div>
      </div>
    </div>

    <div class="slide" id="slide-3">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <div class="slide__text">
          <h1 id="slide-3-title">Slide 3 title</h1>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
        </div>
        <div class="slide__image">
          <svg viewBox="0 0 400 425" width="400" height="425"><use xlink:href="#polaroid"/></svg>
        </div>
      </div>
    </div>

    <div class="slide" id="slide-4">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <div class="slide__text">
          <h1 id="slide-4-title">Slide 4 title</h1>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
        </div>
        <div class="slide__image">
          <svg viewBox="0 0 400 425" width="400" height="425"><use xlink:href="#polaroid"/></svg>
        </div>
      </div>
    </div>

    <div class="slide" id="slide-5">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <div class="slide__text">
          <h1 id="slide-5-title">Slide 5 title</h1>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
        </div>
        <div class="slide__image">
          <svg viewBox="0 0 400 425" width="400" height="425"><use xlink:href="#polaroid"/></svg>
        </div>
      </div>
    </div>

    <div class="slide" id="slide-6">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <div class="slide__text">
          <h1 id="slide-6-title">Slide 6 title</h1>
          <p>Bacon ipsum dolor amet alcatra beef meatloaf brisket beef ribs meatball tenderloin shank ball tip ribeye pig pastrami filet mignon. Sirloin tail fatback venison shank salami. Picanha pastrami venison meatball kevin pork chop leberkas. Meatloaf tenderloin leberkas pancetta hamburger cow kielbasa, filet mignon tri-tip beef ribs.</p>
        </div>
        <div class="slide__image">
          <svg viewBox="0 0 400 425" width="400" height="425"><use xlink:href="#polaroid"/></svg>
        </div>
      </div>
    </div>

  </div>
              
            
!

CSS

              
                
/* demo styles
--------------------------------------------- */

body {
  font: 120% / 1.5 Arial;
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

h1, p {
  margin-bottom: 1.5em;
}

body > svg {
  display: none;
}


/* demo nav bar
--------------------------------------------- */

.nav {
  position: fixed;
  z-index: 100;
  right: 1em;
  top: 50%;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
  display: none;
}
.nav li {
  list-style: none;
  margin: .5em;
}
.nav a {
  display: inline-block;
  padding: .5em 1em;
  color: #fff;
  border-radius: 3px;
  background: rgba(0,0,0,.6);
}
.nav a:not(:hover) {
  text-decoration: none;
}


/* slide layout
--------------------------------------------- */

.slide {
  position: relative;
  padding: 8% 0;
}
.slide__content {
  max-width: 1200px;
  margin: auto;
}
.slide__text, .slide__image {
  padding: 8%;
}
.slide__image svg {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: auto;
}
.slide__bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
}

/* slide backgrounds */

#slide-1 .slide__bg {
  background-image: repeating-linear-gradient(
    rgb(102, 204, 102),
    rgb(102, 204, 102) 30px,
    rgb(92, 184, 92) 30px,
    rgb(92, 184, 92) 60px
  );
}  
#slide-2 .slide__bg {
  background-image: repeating-linear-gradient(
    45deg,
    rgb(133, 173, 230),
    rgb(133, 173, 230) 30px,
    rgb(113, 153, 210) 30px,
    rgb(113, 153, 210) 60px
  );
}
#slide-3 .slide__bg {
  background-image: repeating-linear-gradient(
    rgb(153, 216, 101),
    rgb(153, 216, 101) 30px,
    rgb(133, 196, 81) 30px,
    rgb(133, 196, 81) 60px
  );
}
#slide-4 .slide__bg {
  background-image: repeating-linear-gradient(
    -45deg,
    rgb(133, 193, 230),
    rgb(133, 193, 230) 30px,
    rgb(113, 173, 210) 30px,
    rgb(113, 173, 210) 60px
  );
}
#slide-5 .slide__bg {
  background-image: repeating-linear-gradient(
    rgb(214, 229, 100),
    rgb(214, 229, 100) 30px,
    rgb(194, 209, 80) 30px,
    rgb(194, 209, 80) 60px
  );
}
#slide-6 .slide__bg {
  background-image: repeating-linear-gradient(
    45deg,
    rgb(133, 213, 230) 0px,
    rgb(133, 213, 230) 30px,
    rgb(113, 193, 210) 30px,
    rgb(113, 193, 210) 60px
  );
}


/* misc
--------------------------------------------- */

.demo__info {
  position: fixed;
  width: 100%;
  bottom: 0;
  font-size: 80%;
  text-align: center;
  background: rgba(255,255,255,.5);
  padding: 0.5em;
  z-index: 100;
}


/* Large screen layout
--------------------------------------------- */  

@media screen and (min-width: 45em) {

  .slide__content {
    display: -webkit-flex;
    display: flex;
    align-items: center;
  }
  .slide__image, .slide__text {
    padding: 3%;
    -webkit-flex: 1;
    flex: 1;
  } 
  .slide:nth-child(2n) .slide__text {
    -webkit-order: 1;
    order: 1;
  }
  .nav {
    display: block;
  }

  /* parallax */
  @supports ((perspective: 1px) and (not (-webkit-overflow-scrolling: touch))) {

    html, body {
      overflow: hidden;
      height: 100%;
    }
    body {
      transform: translateZ(0px); /* Fix paint issues in Edge && Safari H/W acceleration */
    }
    .slides {
      position: absolute;
      width: 100%;
      height: 100%;
      overflow-x: hidden;
      overflow-y: auto;
      perspective: 300px;
      scroll-behavior: smooth;
    }
    .slide, .slide__content {
      transform-style: preserve-3d;
    }
    .slide__text {
      transform: translateZ(60px) scale(.8);
      transform-origin: 100% 50%;
    }
    .slide:nth-child(2n) .slide__image {
      transform: translateZ(100px) scale(.67);
      transform-origin: 100% 50%;
    }
    .slide:nth-child(2n) .slide__text {
      transform-origin: 0% 50%;
    }
    .slide:nth-child(2n) .slide__bg {
      transform: translateZ(59px) scale(.85);
    }
    .slide:nth-child(2n+1):not(:first-child) .slide__bg {
      top: -50%;
    }
    .slide:nth-child(2n+1):not(:last-child) .slide__bg {
      bottom: -50%;
    }
    .slide:first-child {
      padding-top: 14%;
    }
    .slide:last-child {
      padding-bottom: 14%;
    }
    .slide:nth-child(2n) {
      z-index: 1; /* ensure slides overlay correctly */
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console