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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="header"></div>
<div class="flex">
  <div class="item-fixed">
    <img src="https://images.pexels.com/photos/1975342/pexels-photo-1975342.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="">
    <img src="https://images.pexels.com/photos/7421250/pexels-photo-7421250.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="">
  </div>
  <div class="item">
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Cum quas unde deleniti ipsam rem quod id ut natus laudantium architecto odio temporibus necessitatibus voluptatibus, libero ullam ea adipisci culpa omnis ab, beatae tempora facilis blanditiis nesciunt ipsa! Nam iure, dignissimos quisquam veritatis qui nihil similique alias cumque rem omnis consequatur eligendi, neque perspiciatis quae repellat possimus id ipsam assumenda? Beatae impedit corporis aliquid. Eos laborum fuga iusto commodi assumenda natus architecto aliquid ab corrupti illum temporibus aut unde, consequuntur voluptatum hic a iure ipsa laudantium aperiam repellendus obcaecati praesentium eaque cumque similique! Deserunt voluptas autem commodi iste, earum vitae nesciunt!

    Lorem ipsum, dolor sit amet consectetur adipisicing elit. Animi ullam sunt fuga necessitatibus fugiat molestias, vitae provident natus recusandae quasi quisquam unde ipsum quibusdam! Nostrum cumque facere dolorem, autem repellendus reiciendis praesentium? Totam minima nisi at deleniti iste, optio quae, cupiditate ratione eligendi placeat labore deserunt laborum quibusdam nulla ex! Eveniet tenetur repellendus aspernatur enim delectus dignissimos illum necessitatibus saepe ipsum harum alias beatae sapiente officia dolores nobis, at vero voluptates minus perspiciatis perferendis molestiae sint. In deserunt pariatur fugit magni laborum vero voluptatibus quas obcaecati saepe at impedit labore corrupti doloribus cupiditate dignissimos, provident aspernatur aliquid possimus itaque cumque? Corporis eum, nostrum dolor quas sunt eaque obcaecati delectus, a maiores et libero architecto, quos officia nemo vero! Recusandae illo qui dignissimos quasi. Incidunt veniam repellat molestias commodi. Quibusdam, cum. Quisquam cumque dolores ab cupiditate similique, deserunt ex possimus exercitationem maxime corporis, commodi laboriosam repudiandae debitis ratione recusandae distinctio excepturi aperiam. Unde magnam nobis aspernatur voluptatem dolor odit, in dicta reprehenderit deleniti, velit distinctio error natus hic. Molestiae cupiditate eos, ullam praesentium, similique quam magnam cumque autem id, facere consequuntur magni. Nihil, odit sit, modi autem aliquid nemo neque adipisci, maxime suscipit dolorem libero quisquam accusamus facilis repellendus corporis. Perferendis?
  </div>
  <div class="item-fixed">
    <img src="https://images.pexels.com/photos/5325837/pexels-photo-5325837.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="">
    <img src="https://images.pexels.com/photos/7974362/pexels-photo-7974362.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="">
  </div>
</div>
              
            
!

CSS

              
                .header {
  height: 100px;
}

img {
  display: block;
  max-width: 100%;
  object-fit: cover;
}

.flex {
  display: flex;
}

.item-fixed,
.item {
  width: 100%;
}

.item {
  height: 2000px;
  padding: 0 10px;
}

.item-fixed {
  transition: 0.34s ease;
}

              
            
!

JS

              
                let fix = document.querySelectorAll(".item-fixed");

window.addEventListener("scroll", function () {
  let scroller = pageYOffset;
  let coof = scroller * 0.5;
  fix.forEach(function (element) {
    if ((scroller) => 0) {
      element.style.transform = `translate(0, ${coof}px)`;
    }
  });
});

              
            
!
999px

Console