Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container">
  <div class="web-page">
    <div class="dynamic-content-wrapper" id="wrapper-1">
    </div>
    <h1>My Article</h1>
    <p>
      See, if you start reading this article you'll notice eventually that you lose your place, because an ad jumps in and shifts all the content from under your eyes.
    </p>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi eaque adipisci vitae vero debitis reprehenderit modi molestiae quasi sapiente porro rerum, quos qui culpa suscipit nam cumque nesciunt ex? Dolorem!
    </p>
  </div>
  <div class="web-page">
    <div class="dynamic-content-wrapper" id="wrapper-2">
    </div>
    <h1>My Article</h1>
    <h3>(Slides down if layout shifts!)</h3>
    <p>
      This article, on the other hand (clearly a much better article), will not. The space has already been reserved at the top, and it won't shove your article out of the way when the ad gets around to arriving.
    </p>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis veniam accusantium similique officia laborum excepturi quod, porro dignissimos sint doloribus magnam accusamus eius voluptate dolorum assumenda. Similique, sequi tenetur quod!
    </p>
  </div>
</div>
            
          
!
            
              /* Just for visuals; not relevant to what's being demonstrated */

body {
  background-color: #B2EBF2;
  font: 14px Sans-Serif;
}

.container {
  text-align: center;
  padding: 10px 5px;
}

.web-page {
  padding: 15px;
  display: inline-block;
  width: 25%;
  min-width: 180px;
  max-width: 300px;
  height: 300px;
  margin: 10px;
  border: 2px black solid;
  overflow-y: scroll;
  text-align: left;
  background-color: white;
}

.dynamic-content {
  height: 100px;
  width: 100%;
  background-color: #0D47A1;
  color: #eee;
  text-align: center;
  line-height: 100px;
  font-size: 16px;
  font-weight: bold;
}

#wrapper-2 {
  height: 0;
  overflow: hidden;
  transition: height 0.66s ease-out;
}
#wrapper-2.loaded {
  height: 100px;
}
            
          
!
            
              /* Simulate an ajax-loaded ad with a delayed DOM insertion */
setTimeout(function() {
  $('#wrapper-1').html('<div class="dynamic-content">Ad 😠</div>');
}, 2000);

setTimeout(function() {
  var el = $('#wrapper-2');
  el.html('<div class="dynamic-content">Ad 😊</div>');
  onLoad(el);
}, 2000);

function onLoad(element) {
  $(element).addClass('loaded');
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console