cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <div class="animation-type">Animation type: </div>
<h1>Animate with <span class="animation-name"></span></h1>

<div id="animate" class=macbook></div>
            
          
!
            
              #animate {
  animation-duration: 3s;
  animation-timing-function: ease;
  animation-iteration-count: infinite;
}

.top-left #animate {
  animation-name: move-top-left;
}

.translate #animate {
  animation-name: move-translate;
}

@keyframes move-top-left {
  50% {
    top: 200px;
    left: 200px;
  }
}

@keyframes move-translate {
  50% {
    transform: translate(100px, 100px);
  }
}

input[type="radio"]{
  display: inline-block;
  margin: 0 5px 0 20px;
}

h1 {
  padding: 90px;
}
body {
  color: white;

  background: radial-gradient(
        hsl(0, 100%, 27%) 4%,
        hsl(0, 100%, 18%) 9%,
        hsla(0, 100%, 20%, 0) 9%
      )
      0 0,
    radial-gradient(
        hsl(0, 100%, 27%) 4%,
        hsl(0, 100%, 18%) 8%,
        hsla(0, 100%, 20%, 0) 10%
      )
      50px 50px,
    radial-gradient(hsla(0, 100%, 30%, 0.8) 20%, hsla(0, 100%, 20%, 0)) 50px 0,
    radial-gradient(hsla(0, 100%, 30%, 0.8) 20%, hsla(0, 100%, 20%, 0)) 0 50px,
    radial-gradient(hsla(0, 100%, 20%, 1) 35%, hsla(0, 100%, 20%, 0) 60%) 50px 0,
    radial-gradient(hsla(0, 100%, 20%, 1) 35%, hsla(0, 100%, 20%, 0) 60%) 100px
      50px,
    radial-gradient(hsla(0, 100%, 15%, 0.7), hsla(0, 100%, 20%, 0)) 0 0,
    radial-gradient(hsla(0, 100%, 15%, 0.7), hsla(0, 100%, 20%, 0)) 50px 50px,
    linear-gradient(
        45deg,
        hsla(0, 100%, 20%, 0) 49%,
        hsla(0, 100%, 0%, 1) 50%,
        hsla(0, 100%, 20%, 0) 70%
      )
      0 0,
    linear-gradient(
        -45deg,
        hsla(0, 100%, 20%, 0) 49%,
        hsla(0, 100%, 0%, 1) 50%,
        hsla(0, 100%, 20%, 0) 70%
      )
      0 0;
  background-color: #300;
  background-size: 100px 100px;
}

#animate {
  position: absolute;
  top: 100px;
  left: 100px;
}

.macbook {
  background-color: #082746;
  background-image: linear-gradient(
      70deg,
      transparent 67%,
      hsla(0, 0%, 100%, 0.05) 67%,
      hsla(0, 0%, 100%, 0.025)
    ),
    linear-gradient(#ddd 11px, transparent 11px),
    linear-gradient(#132d4e, #4f7d90);
  border-radius: 8px 8px 0 0;
  box-shadow: inset 0 1px 1px 1px #000, inset 0 0 0 9px #111, 0 0 0 1px #ccc,
    0 0 1px 2px hsla(0, 0%, 0%, 0.4), 0 0 50px hsla(0, 0%, 0%, 0.3),
    0 0 100px hsla(0, 0%, 0%, 0.5), 0 0 200px hsla(0, 0%, 0%, 0.5);
  height: 100px;
  display: block;
  left: 50%;
  margin: -50px -75px;
  position: absolute;
  top: 50%;
  width: 150px;
}
.macbook:after {
  background-color: #ddd;
  background-image: linear-gradient(
    left,
    hsla(0, 0%, 0%, 0.3),
    hsla(0, 0%, 100%, 0.4) 2%,
    hsla(0, 0%, 100%, 0.1) 5%,
    hsla(0, 0%, 0%, 0.2) 95%,
    hsla(0, 0%, 100%, 0.2) 98%,
    hsla(0, 0%, 0%, 0.4)
  );
  border-bottom: 3px solid hsla(0, 0%, 40%, 0.75);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 3px 7px hsla(0, 0%, 0%, 0.1);
  content: "";
  height: 7px;
  left: -22px;
  position: absolute;
  right: -22px;
  top: 100%;
}
.macbook:before {
  background-color: #222;
  border-radius: 100%;
  box-shadow: inset 1px 1px 0 hsla(0, 0%, 100%, 0.1), -13px 96px 0 -1px #888,
    -13px 97px 0 -1px #888, -11px 97px 0 #888, -9px 97px 0 #888,
    -7px 97px 0 #888, -5px 97px 0 #888, -3px 97px 0 #888, -1px 97px 0 #888,
    1px 97px 0 #888, 3px 97px 0 #888, 5px 97px 0 #888, 7px 97px 0 #888,
    9px 97px 0 #888, 11px 97px 0 #888, 13px 97px 0 -1px #888,
    13px 96px 0 -1px #888, 80px 99px 0 -1px #666, 81px 99px 0 -1px #666,
    82px 99px 0 -1px #666, 83px 99px 0 -1px #666, 84px 99px 0 -1px #666,
    85px 99px 0 -1px #666;
  content: "";
  height: 3px;
  left: 50%;
  margin-left: -2px;
  position: absolute;
  top: 3px;
  width: 3px;
  z-index: 1;
}

            
          
!
            
              var animations = ["top-left", "translate"];

animations.forEach(anim => {
  $(".animation-type").append(
    `<label><input type="radio" name="animation-type" value="${anim}">${anim}</label>`
  );
});

$('input[type="radio"]').on('change', function(){
  console.log('this.value', this.value);
  setAnimation(this.value);
});

$('input[type="radio"]').eq(0).click();

function setAnimation(animName) {
  animations.forEach(anim => {
    document.body.classList.remove(anim);
  });

  $(".animation-name").text(animName);

  document.body.classList.add(animName);
}

var machines = 10;

$("<button></button")
  .text("clear")
  .click(function moar() {
    $("[id=animate]")
      .slice(1)
      .remove();
  })
  .prependTo("body");

$("<button></button")
  .text("add " + machines + " more macbooks")
  .click(function moar() {
    $("#animate")
      .clone()
      .insertAfter("#animate");
    if (machines-- > 0) setTimeout(moar, 15);
  })
  .prependTo("body");

            
          
!
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.
Loading ..................

Console