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="flex flex-with-gutter between container planet">
  <div class="flex flex-column flex-12">
  <div class="flex flex-column flex-6">
    <div class="image-normal">
      <img src="https://images.unsplash.com/photo-1449247709967-d4461a6a6103?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=f221ed1b6e78feba8f81d3ccbb657877" srcset="https://images.unsplash.com/photo-1449247709967-d4461a6a6103?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=f221ed1b6e78feba8f81d3ccbb657877 1x, https://images.unsplash.com/photo-1449247709967-d4461a6a6103?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=f221ed1b6e78feba8f81d3ccbb657877 2x" class="radius">
    <h2 class="db pt2 f5-l mb0">No lazy loading</h2>
    <p class="f6-l">Regular src/srcset</p>
  <div class="flex flex-column flex-6">
    <div class="image bg-blue loading">
      <img data-src="https://images.unsplash.com/photo-1499744632587-7798360ba20f?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=e6829357bb53d9e2efd96e3b043a3b3a" data-srcset="https://images.unsplash.com/photo-1499744632587-7798360ba20f?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=e6829357bb53d9e2efd96e3b043a3b3a 1x, https://images.unsplash.com/photo-1499744632587-7798360ba20f?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&s=e6829357bb53d9e2efd96e3b043a3b3a 2x" class="lazyload">
    <h2 class="db pt2 f5-l mb0">With lazy loading</h2>
    <p class="f6-l">data-src/data-srcset attributes</p>
              // Loading
// ---------------------------
@keyframes scaleout {
  0% {
    transform: scale(0); }

  100% {
    transform: scale(1);
    opacity: 0; } }

.image {
  position: relative;
  padding-bottom: 66.5492958%;
  // Tweak as needed
  background: linear-gradient(rgb(242, 242, 242) 66%, rgba(242, 242, 242, 0));

  img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; } }

.loading:before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  margin-top: -16px;
  margin-left: -16px;
  width: 32px;
  height: 32px;
  border-radius: 32px;
  animation: scaleout 1.2s infinite ease-in-out;

  // Tweak as needed
  mix-blend-mode: soft-light;
  background-color: rgba(0, 0, 0, .9); }

// Lazyloaded images
// ---------------------------
.lazyloading {
	opacity: 0; }

.image {
	opacity: 1;
	transition: 1s cubic-bezier(0.215, 0.61, 0.355, 1); }

// For layout & setup
// ---------------------
.container {
  flex-flow: row wrap;
  max-width: 960px;
  margin: auto; }

.image {
  position: relative;
  padding-bottom: 66.5492958%;

  &, img {
    border-radius: 4px; }

  img {
    position: absolute;
    top: 0;
  	left: 0;
    max-width: 100%;
    max-height: 100%;
    z-index: 2; } }

.bg-blue {
  background: #C8E5EE; }
              const lazy = () => {
  document.addEventListener('lazyloaded', (e) => {

🕑 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.