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

              
                <button id="js-btn-lazy-load-more">Meer publicaties ▸</button>

<div class="grid" id="js-lazy-items-container">
  <div class="js-lazy-item">
     One Flew Over the Cuckoo's Nest
  </div>
  <div class="js-lazy-item">
     Lock, Stock and Two Smoking Barrels
  </div>
  <div class="js-lazy-item">
    The Three Musketeers
  </div>
  <div class="js-lazy-item">
    I Am Number Four
  </div>
  <div class="js-lazy-item">
     The Fifth Element
  </div>
  <div class="js-lazy-item">
    The Sixth Sense
  </div>
  <div class="js-lazy-item">
    Seven Years in Tibet
  </div>
  <div class="js-lazy-item">
    8 Mile
  </div>
  <div class="js-lazy-item">
    9
  </div>
  <div class="js-lazy-item">
     10 Things I Hate About You 
  </div>
  <div class="js-lazy-item">
    Ocean's Eleven
  </div>
  <div class="js-lazy-item">
    Twelve Monkeys
  </div>
  <div class="js-lazy-item">
    Apollo 13
  </div>
  <div class="js-lazy-item">
    14 Cameras
  </div>
  <div class="js-lazy-item">
    15 Minutes
  </div>
  <div class="js-lazy-item">
    Sixteen Candles
  </div>
  <div class="js-lazy-item">
    17 Again
  </div>
</div>
              
            
!

CSS

              
                body {
  background-color: #276D9B;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  color: #F1F3F8;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  grid-gap: 1em;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.grid * {
  display: flex;
  align-items: center;
  background-color: #0C2231;
  padding: 1em;
  font-size: 20px;
  font-weight: bold;
}

button {
  background-color: #0C2231;
  border: 2px solid #F1F3F8;
  border-radius: 5px;
  color: #F1F3F8;
  margin-left: 2em;
  margin-bottom: 2em;
  padding: 1em 2em;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
}
              
            
!

JS

              
                // This script emulates lazy loading, also in IE11

(function() {
    var items = [].slice.call(document.getElementsByClassName('js-lazy-item'));
    var initialItems = 3;
    var desiredItems = 3; // Desired number of items to lazy load
    var lazyLoadItems = [];
    var btnLoadMore = document.getElementById('js-btn-lazy-load-more');
    var itemsContainer = document.getElementById('js-lazy-items-container');
    
    // Disable button if there are less items than the desired number of items
    if (items.length <= initialItems) {
        btnLoadMore.disabled = true;
    // Remove more than the desired number of items
    } else if (items.length > initialItems) {
        var sliceItems = items.slice(initialItems, items.length);
        sliceItems.forEach(function(element) {
            lazyLoadItems.push(element); // Store items for later use
            element.parentNode.removeChild(element); // Remove items from DOM
        });
    }

    btnLoadMore.addEventListener('click', function() {
        // Splice array in multiple arrays of the desired number of items
        var splicedItems = lazyLoadItems.splice(desiredItems);
        
        // Place desired number of items back into the DOM
        lazyLoadItems.forEach(function(element) {
            itemsContainer.appendChild(element);
        });
        
        // Create new array with the leftover items to repeat the step above
        lazyLoadItems = splicedItems;
        
        // Disable button when all items are on the page
        if (lazyLoadItems.length < 1) {
            btnLoadMore.disabled = true;
        }
    });
}());
              
            
!
999px

Console