123

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.

            
              section.fanned

  div.artwork(el=".artwork")
    p .artwork
    div.artwork__lighting(el=".artwork__lighting")
      p .artwork__lighting
      picture.artwork__image(el=".artwork__image")
        img(src="https://unsplash.it/200")

  div
    button#fan-button Fan/Unfan
    p From back-to-front. Check/uncheck to show/hide:
    ol.showhide
      li
        input#o(type="checkbox" data-target=".artwork" data-ps="bg" checked)
        label(for="o") .artwork
      li
        input#ob(type="checkbox" data-target=".artwork" data-ps="before" checked)
        label(for="ob") .artwork::before
        ol
          li
            input#i(type="checkbox" data-target=".artwork__lighting" data-ps="bg" checked)
            label(for="i") .artwork__lighting
          li
            input#ib(type="checkbox" data-target=".artwork__lighting" data-ps="before" checked)
            label(for="ib") .artwork__lighting::before
            ol
              li
                input#c1(type="checkbox" data-target=".artwork__image" data-ps="bg" checked)
                label(for="c1") .artwork__image
                ol
                  li
                    input#c1b(type="checkbox" data-target=".artwork__image" data-ps="before" checked)
                    label(for="c1b") .artwork__image::before
                  li
                    input#c1a(type="checkbox" data-target=".artwork__image" data-ps="after" checked)
                    label(for="c1a") .artwork__image::after
          li
            input#ia(type="checkbox" data-target=".artwork__lighting" data-ps="after" checked)
            label(for="ia") .artwork__lighting::after
      li
        input#oa(type="checkbox" data-target=".artwork" data-ps="after" checked)
        label(for="oa") .artwork::after
            
          
!
            
              :root {
  --outer-bg: antiquewhite;
  --inner-bg: powderblue;
  --artwork__image-bg: palegreen;
}

$fan: 0.67rem;

.artwork, .artwork__lighting, .artwork__image {
  width: 400px;
  height: 13 * 1.2rem;
  font-size: 2rem;
  
  &, &::before, &::after {
    color: black;
    outline: 1px solid transparent;
    transition: transform 1s, outline 0.2s, margin 1s;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.95;
  }
  
  &::after, &::before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

.artwork {
  min-width: 400px;
  position: relative;
  margin-right: 1em;
  --bg: var(--outer-bg);
}

.artwork__lighting, .artwork__image {
  position: absolute;
  top: 0; left: 0;
}

.artwork__lighting {
  --bg: var(--inner-bg);
}

.artwork__image {
  --bg: var(--artwork__image-bg);
}

.artwork, .artwork__lighting, .artwork__image {
  &::before {
    content: attr(el) "::before";
  }
  &::after {
    content: attr(el) "::after";
  }
}

.hidden-before::before,
.hidden-after::after {
  display: none !important;
}

.hidden-bg {
  background: transparent;
  color: transparent;
  outline: none !important;
}

.hidden-bg img {
  display: none !important;
}

[for^=o] { background: var(--outer-bg); }
[for^=i] { background: var(--inner-bg); }
[for^=c1] { background: var(--artwork__image-bg); }

.fanned {
  .artwork, .artwork__lighting, .artwork__image, ::after, ::before {
    outline-color: gray;
  }
  
  .artwork {
    margin-right: $fan * 12;
    transform: skew(0deg, -10deg);
    &::before {
      transform: translate3d($fan, $fan, 0px);
    }
    &::after {
      transform: translate3d($fan * 8, $fan * 8, 0px);
    }
  }
  
  .artwork__lighting {
    transform: translate3d($fan * 2, $fan * 2, 0px);
    &::before {
      transform: translate3d($fan, $fan, 0px);
    }
    &::after {
      transform: translate3d($fan * 5, $fan * 5, 0px);
    }
  }
  
  .artwork__image {
    transform: translate3d($fan * 2, $fan * 2, 0px);
    &::before {
      transform: translate3d($fan, $fan, 0px);
    }
    &::after {
      transform: translate3d($fan * 2, $fan * 2, 0px);
    }
  }
}

// Basic styles

html {
  font-family: sans-serif;
  line-height: 1.2;
}

p {
  margin: 0;
}

section {
  display: flex;
}

ol {
  margin: 0;
  font-family: monospace;
  list-style-position: inside;
  padding-left: 0.5em;
  list-style-type: disc;
  > li > ol { list-style-type: circle;
    > li > ol { list-style-type: square;
      > li > ol { list-style-type: disc; }
    }
  }
}

            
          
!
            
              document.addEventListener("DOMContentLoaded", function() {
  var inputs = document.getElementsByTagName("input");
  for (var i = 0; i < inputs.length; i++) {
    inputs[i].addEventListener("change", function(e) {
      var targetClass = e.target.dataset.target;
      var ps = e.target.dataset.ps;

      var targetElement = document.querySelector(targetClass);
      document.querySelector(targetClass).classList.toggle('hidden-' + ps);
    });
  }

  var fanButton = document.querySelector("#fan-button");
  fanButton.addEventListener("click", function(e) {
    var section = document.querySelector('section');
    section.classList.toggle('fanned');
  })
});


            
          
!
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