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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="🐙">
  <div class="arm"></div>
  <div class="arm"></div>
  <div class="arm"></div>
  <div class="arm"></div>
  <div class="arm"></div>
  <div class="arm"></div>
  <div class="arm"></div>
  <div class="arm"></div>
</div>
<div class="⚪️"></div>
<div class="⚪️"></div>
<div class="aniToggle">
  <input id="animate" name="animate" type="checkbox" checked />
  <label for="animate">Animation</label>
</div>
              
            
!

CSS

              
                $body: mediumvioletred;
$bg-size: 25vmin;
$speed: 1s;
html, body {height: 100%}
@keyframes down {
  from {
    background-position: center $bg-size/2;
    background-position: center $bg-size*1.5;
  }
  to {
    background-position: center $bg-size*1.5;
    background-position: center calc(#{$bg-size * 0.9 / 1.5});
  }
}
body {
  &.animate {
    animation: down $speed linear infinite;
  }
  align-items: center;
  background-color: midnightblue;
  background-image:
    radial-gradient(
      circle at $bg-size*.75 0,
      transparent,
      transparent $bg-size/4,
      rgba(cyan, 0.1) $bg-size/4,
      rgba(cyan, 0.1) $bg-size/2,
      transparent $bg-size/2
    ),
    radial-gradient(
      circle at $bg-size*1.5 $bg-size*.9,
      transparent,
      transparent $bg-size/4,
      rgba(cyan, 0.1) $bg-size/4,
      rgba(cyan, 0.1) $bg-size/2,
      transparent $bg-size/2
    ),
    radial-gradient(
      circle at 0 $bg-size*.9,
      transparent,
      transparent $bg-size/4,
      rgba(cyan, 0.1) $bg-size/4,
      rgba(cyan, 0.1) $bg-size/2,
      transparent $bg-size/2
    )
  ;
  background-position: center $bg-size/2;
  background-size: $bg-size*1.5 $bg-size*.9;
  display: flex;
  justify-content: center;
  margin: 0;
  overflow: hidden;
}
.🐙 {
  background-color: $body;
  background-image: radial-gradient(
    circle at center 15vmin,
    rgba(white, 0.125),
    rgba(white, 0) 33%
  );
  border-radius: 100%;
  box-shadow: inset 0 4vmin 4vmin rgba(black, 0.125);
  height: 50vmin;
  margin-top: -10vmin;
  position: relative;
  width: 50vmin;
  &::before {
    background-image:
      // highlight
      radial-gradient(
        circle at 7.5vmin 6vmin,
        #fffc 1vmin,
        transparent 1.1vmin,
      ),
      radial-gradient(
        circle at 32.5vmin 6vmin,
        #fffc 1vmin,
        transparent 1.1vmin,
      ),
      // pupils
      radial-gradient(
        circle at 7.5vmin center,
        black 4.9vmin,
        transparent 5vmin,
      ),
      radial-gradient(
        circle at 32.5vmin center,
        black 4.9vmin,
        transparent 5vmin,
      ),
      // under pupil highlight
      radial-gradient(
        circle at 7.5vmin 8vmin,
        rgba(white, 0.33) 4.5vmin,
        transparent 5vmin,
      ),
      radial-gradient(
        circle at 32.5vmin 8vmin,
        rgba(white, 0.33) 4.5vmin,
        transparent 5vmin,
      ),
      // sockets
      radial-gradient(
        circle at 7.5vmin center,
        darken($body, 5%) 5.5vmin,
        darken($body, 10%) 7.3vmin,
        darken($body, 10%) 7.4vmin,
        transparent 7.5vmin
      ),
      radial-gradient(
        circle at 32.5vmin center,
        darken($body, 5%) 5.5vmin,
        darken($body, 10%) 7.3vmin,
        darken($body, 10%) 7.4vmin,
        transparent 7.5vmin
      )
    ;
    bottom: 10vmin;
    content: '';
    height: 15vmin;
    left: 5vmin;
    position: absolute;
    width: 40vmin;
  }
  .animate & {
    animation: bounce $speed infinite alternate;
  }
}
@keyframes bounce {
  from {
    margin-top: -10vmin;
  }
  to {
    margin-top: 0;
  }
}
@function bubble($size, $position) {
  @return radial-gradient(
    circle at $position,
    transparent calc(#{$size} - 4px),
    rgba(#fff, 0.8) calc(#{$size} - 3px),
    rgba(#fff, 0.8) calc(#{$size} - 1px),
    transparent $size
  )
}
.⚪️ {
  $bubble1: 3vmin;
  $bubble2: 2vmin;
  background-image:
    bubble(3vmin, 3vmin 3vmin),
    bubble(2vmin, 9vmin 9vmin),
    bubble(1vmin, 3vmin 15vmin),
  ;
  height: 20vmin;
  right: 8vmin;
  position: absolute;
  top: 10vmin;
  width: 20vmin;
  z-index: -2;
  &:nth-child(2) {
    bottom: 10vmin;
    left: 10vmin;
    top: auto;
  }
  .animate & {
    animation: float $speed*5 linear infinite;
    &:nth-child(2) {
      animation-delay: $speed*2;
      top: calc(100% + 20vmin);
    }
  }
}
@keyframes float {
  from {
    background-position: 0 0;
    top: calc(100% + 20vmin);
    transform: scale(1);
  }
  50% {
    background-position:
      5vmin 5vmin,
      7vmin 8vmin,
      5vmin 0
    ;
    transform: scale(2);
  }
  to {
    background-position: 0 0;
    top: -20vmin;
    transform: scale(1.5);
  }
}
$deg-18: 60deg;
$mb-18: 10vmin;
$x-18: 22vmin;
$deg-27: 45deg;
$mb-27: 1vmin;
$x-27: 18vmin;
$deg-36: 30deg;
$mb-36: -6vmin;
$x-36: 11vmin;
$deg-45: 15deg;
$mb-45: -10vmin;
$x-45: 1.5vmin;
.arm {
    background-color: $body;
    border-radius: 4vmin;
    bottom: 0;
    height: 16vmin;
    position: absolute;
    right: 50%;
    width: 8vmin;
    z-index: -1;
    $shadow: linear-gradient(rgba(black, 0.25), transparent 67%);
  &::before,
  &::after {
    $light: lighten($body, 25%);
    background-color: $light;
    border-radius: 100%;
    bottom: 1vmin;
    box-shadow: inset 1vmin 0vmin 0 darken($body, 15%);
    content: '';
    height: 2.5vmin;
    position: absolute;
    right: 0;
    width: 2.5vmin;
  }
  &::after {
    bottom: 6vmin;
  }
  & {
    background-image:
      $shadow,
      linear-gradient(
        to left,
        rgba(black, 0.25) 50%,
        transparent 50%
    );
  }
  &:nth-child(n + 5) {
    background-image:
      $shadow,
      linear-gradient(
        to right,
        rgba(black, 0.25) 50%,
        transparent 50%
    );
    left: 50%;
    &::before,
    &::after {
      left: 0;
      box-shadow: inset -1vmin 0vmin 0 darken($body, 15%);
    }
  }
  &:first-child,
  &:last-child,
  &:nth-child(2),
  &:nth-child(7) {
    background-color: darken($body, 10%);
    &::before,
    &::after {
      background-color: $body;
      box-shadow: inset 1vmin 0vmin 0 darken($body, 25%);
    }
  }
  &:last-child,
  &:nth-child(7) {
    &::before,
    &::after {
      box-shadow: inset -1vmin 0vmin 0 darken($body, 25%);
    }
  }
  // individual arm positioning
  &:first-child {
    margin-bottom: $mb-18;
    transform:
      translateX(-#{$x-18})
      rotate(#{$deg-18})
    ;
  }
  &:nth-child(2) {
    margin-bottom: $mb-27;
    transform:
      translateX(-#{$x-27})
      rotate(#{$deg-27})
    ;
  }
  &:nth-child(3) {
    margin-bottom: $mb-36;
    transform:
      translateX(-#{$x-36})
        rotate(#{$deg-36})
    ;
  }
  &:nth-child(4) {
    margin-bottom: $mb-45;
    transform:
      translateX(-#{$x-45})
      rotate(#{$deg-45})
    ;
  }
  &:nth-child(5) {
    margin-bottom: $mb-45;
    transform:
      translateX(#{$x-45})
      rotate(-#{$deg-45})
    ;
  }
  &:nth-child(6) {
    margin-bottom: $mb-36;
    transform:
      translateX(#{$x-36})
      rotate(-#{$deg-36})
    ;
  }
  &:nth-child(7) {
    margin-bottom: $mb-27;
    transform:
      translateX(#{$x-27})
      rotate(-#{$deg-27})
    ;
  }
  &:last-child {
    margin-bottom: $mb-18;
    transform:
      translateX(#{$x-18})
      rotate(-#{$deg-18})
    ;
  }
  .animate & {
    animation: 500ms linear infinite alternate;
    &:first-child {
      animation-name: arm1;
    }
    &:nth-child(2) {
      animation-name: arm2;
    }
    &:nth-child(3) {
      animation-name: arm3;
    }
    &:nth-child(4) {
      animation-name: arm4;
    }
    &:nth-child(5) {
      animation-name: arm5;
    }
    &:nth-child(6) {
      animation-name: arm6;
    }
    &:nth-child(7) {
      animation-name: arm7;
    }
    &:last-child {
      animation-name: arm8;
    }
  }
}
$deg-ani: 15deg;
@keyframes arm1 {
  from {
    transform: translateX(-#{$x-18}) rotate(#{$deg-18});
  }
  to {
    transform: translateX(-#{$x-18}) rotate(#{$deg-18 + $deg-ani});
  }
}
@keyframes arm2 {
  from {
    transform: translateX(-#{$x-27}) rotate(#{$deg-27});
  }
  to {
    transform: translateX(-#{$x-27}) rotate(#{$deg-27 + $deg-ani});
  }
}
@keyframes arm3 {
  from {
    transform: translateX(-#{$x-36}) rotate(#{$deg-36});
  }
  to {
    transform: translateX(-#{$x-36}) rotate(#{$deg-36 + $deg-ani});
  }
}
@keyframes arm4 {
  from {
    transform: translateX(-#{$x-45}) rotate(#{$deg-45});
  }
  to {
    transform: translateX(-#{$x-45}) rotate(#{$deg-45 + $deg-ani});
  }
}
@keyframes arm5 {
  from {
    transform: translateX(#{$x-45}) rotate(#{-$deg-45});
  }
  to {
    transform: translateX(#{$x-45}) rotate(#{-$deg-45 - $deg-ani});
  }
}
@keyframes arm6 {
  from {
    transform: translateX(#{$x-36}) rotate(#{-$deg-36});
  }
  to {
    transform: translateX(#{$x-36}) rotate(#{-$deg-36 - $deg-ani});
  }
}
@keyframes arm7 {
  from {
    transform: translateX(#{$x-27}) rotate(#{-$deg-27});
  }
  to {
    transform: translateX(#{$x-27}) rotate(#{-$deg-27 - $deg-ani});
  }
}
@keyframes arm8 {
  from {
    transform: translateX(#{$x-18}) rotate(#{-$deg-18});
  }
  to {
    transform: translateX(#{$x-18}) rotate(#{-$deg-18 - $deg-ani});
  }
}
.aniToggle {
  input {
    display: none;
    &:checked ~ label {
      background-color: rgba($body, 0.9);
      &::after {
        content: ' on';
      }
    }
  }
  label {
    background-color: #333;
    border-radius: 1rem;
    color: #fff;
    cursor: pointer;
    font-family: monospace;
    padding: 0.5rem;
    position: absolute;
    right: 1vmin;
    top: 1vmin;
    &::after {
      content: ' off';
      font-weight: bold;
    }
  }
}
              
            
!

JS

              
                const check = document.querySelector('#animate')
check.addEventListener('change', () => {
  document.querySelector('body').classList.toggle('animate')
})
// onload
if (check.checked) document.querySelector('body').classList.add('animate');
              
            
!
999px

Console