cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <div class="page-wrap">
  <header class="container">
    <h1 class="title-project"><a href="https://atelierbram.github.io/lazy-loading-logos/" class="title-project_link"><span class="screen-reader-text">Lazy Loading Logos</span><img data-src="https://atelierbram.github.io/lazy-loading-logos/assets/img/svg/logo-lll_456x60.svg" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='456' height='60' viewBox='0 0 456 60'%3E%3Ctext x='16' y='43' style='text-anchor:start;font-size:44px;font-family:Calibri,AvenirNextCondensed-DemiBold,Segoe UI,Tahoma,sans-serif;font-weight:bold;letter-spacing:-.4px;fill:rgb(34,34,34)'%3ELazy Loading Logos%3C/text%3E%3C/svg%3E" alt="logo for Lazy Loading Logos" class="logo" width="456" height="60"></a></h1>
  </header>

  <main class="container">
    <article>
      <p>Reload the page and see the header image replacement in action.</p>
      <p>Read about more about it <a href="https://codepen.io/atelierbram/post/lazy-loading">in this blogpost</a></p>
      <p class="note">There is an added delay in the javascript function used on this page: this is only for this demo, so not for production use. Use the script at: <code><a href="//atelierbram.github.io/lazy-loading-logos/assets/js/load-img.js">atelierbram.github.io/lazy-loading-logos/assets/js/load-img.js</a></code></p>

    </article>
  </main>


  <footer class="site-footer">
    <small class="colophon">Made by <a href="http://atelierbramdehaan.nl/">Atelier Bram de Haan</a>, on <a href="https://github.com/atelierbram/lazy-loading-logos/">GitHub</a>.</small>
  </footer><a href="https://github.com/atelierbram/lazy-loading-logos/" class="github-corner"><svg width="72" height="72" viewBox="0 0 250 250" style="fill:#2a2734;position:absolute;top:0;border:0;right:0;"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>
</div> 
            
          
!
            
              img {
  max-width: 100%;
  height: auto;
}

.title-project {
  width: 456px;
}

.title-project_link {
  display: block;
  position: relative;
  height: 0;
  padding-bottom: 13.15789473684211%;
}

.logo {
  position: absolute;
  top:0;right:0;bottom:0;left:0;
  width: 100%;
  height: 100%;
}

.screen-reader-text {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}

// general
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
  // outline: 1px dotted salmon;
}

html,
body {
  height: 100%;
  background-color: hsl(144, 43%, 66%);
}

body {
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, Calibri, "Segoe UI", AvenirNext-Regular, Verdana, sans-serif;
  box-sizing: border-box;
}

.page-wrap {
  position: relative;
  padding-bottom: 60px;
  min-height: 100vh;
  background-image: linear-gradient(to bottom, #f0f0f0, #f0f0f0 72px, transparent 0, transparent),url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1000' height='100' viewBox='0 0 1000 100'%3E%3Crect fill='rgb(255,255,255)' width='1200' height='100'/%3E%3C/svg%3E");
  background-repeat: no-repeat, repeat-y;
  background-position: 0 0, center;
}

.container {
  max-width: 56em;
  margin: 0 auto;
}

header {
  padding-top: 4px;
}

main > article {
  padding: 3em 1em;

  @media (min-width: 800px) {
    padding-left: 3em;
    padding-right: 3em;
  }
}

main > article p {
  max-width: 35em;
}

main > article p:first-of-type {
  position: relative;
}

main > article p:first-of-type:after {
  content: "\021EA \00A0 \021EA \00A0 \021EA";
  position: absolute;
  text-align: center;
  top:-1em;right:0;left:0;
  font-size: 3em;
} 

.site-footer {
  position: absolute;
  right:0;bottom:0;left:0;
  height: 60px;
  text-align: center;
  background-color: #f0f0f0;
}

.colophon {
  display: inline-block;
  padding-top: 1.5em;
}

.github-corner {
  visibility: hidden;
  color: #f0f0f0;

  @media (min-width: 517px) {
    visibility: visible;
  }
}

.github-corner:hover {
  color: hsl(144, 43%, 66%);
}

a {
  color: hsl(236, 75%, 45%);
}

h3 {
  text-transform: uppercase;
  color: #222;
  font-size: 1.25em;
  margin-top: 1em;
}

p {
  padding: .5em 0;
}

.note {
  margin: 2em 0 3em;
  padding: 1em 1.5em;
  background-color: hsl(54,77%,83%);
  border-radius: 3px;
}

// IE11 still needs this:
header,
main,
article,
footer {
  display: block;
} 
            
          
!
            
              /*
 * http://blog.simonwillison.net/post/57956760515/addloadevent
 * http://www.sitepoint.com/closures-and-executing-javascript-on-page-load/
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}  

function loadImg(){
  var imgDefer = document.querySelectorAll('[data-src]')

    // Timeout function is only for demo purpose: it adds an delay of half a second
    setTimeout(function() { // this line can be removed, see: https://github.com/atelierbram/lazy-loading-logos/blob/master/docs/assets/js/load-img.js

    for (var i=0; i<imgDefer.length; i++) {
      if(imgDefer[i].getAttribute('data-src')) {

        imgDefer[i].setAttribute('src',imgDefer[i].getAttribute('data-src'));
      }
    }

  }, 500); // this line can be removed, see: load-img.js

}
addLoadEvent(loadImg);
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console