Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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="torso"/>
  <div class="head">
    <div class="l-ear ear"></div>
    <div class="r-ear ear"></div>
    <div class="l-eye eye"></div>
    <div class="r-eye eye"></div>
    <div class="snout">
      <div class="snout-center"></div>
      <div class="l-nostril nostril"></div>
      <div class="r-nostril nostril"></div>
      <div class="l-cheek cheek"></div>
      <div class="r-cheek cheek"></div>
    </div>
  </div>
</div>
<div class="fl-leg leg"></div>
<div class="fr-leg leg"></div>
<div class="br-leg leg"></div>
<div class="bl-leg leg"></div>
</div>
</div>
</div>
  

              
            
!

CSS

              
                $background: #fddce6;
$pig: #ef63a8;
$snout: #ff87b8;

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: $background;
}

// * {
//   box-sizing: border-box;
//   position: absolute;
//   will-change: transform;
// }
[class="🐷"] {
  height: 300px;
  width: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-sizing: border-box;
  // border: 1px solid red;
  // z-index: 0;
  * {
    background-color: $pig;
    border: 8px solid black;
    box-sizing: border-box;
    position: absolute;
  }
  *:before,
  *:after {
    box-sizing: border-box;
    position: relative;
  }
}

.torso {
  width: 175px;
  height: 150px;
  border-radius: 45%;
}
.head {
  width: 200px;
  height: 150px;
  left: -22px;
  top: -75px;
  border-radius: 45%;
  &:before {
    content: ""; // position relative;
  }
}

.ear {
  width: 50px;
  height: 70px;
  top: -30px;
  z-index: -6;
}
.r-ear {
  right: 5px;
  border-top-right-radius: 80%;
  transform: rotate(10deg);
}
.l-ear {
  left: 5px;
  border-top-left-radius: 80%;
  transform: rotate(-10deg);
}
.eye {
  background-color: black;
  width: 1px;
  height: 1px;
  border-radius: 50%;
  top: 25px;
}
@keyframes head-spin {
  from,
  to {
    transform: none;
  }
  25% {
    transform: translateX(-10px) translateY(-10px);
  }
  50% {
    transform: translateX(10px) translateY(-10px);
  }
}
@keyframes ear-spin-left {
  25% {
    transform: rotate(-30deg);
  }
}
@keyframes ear-spin-right {
  25% {
    transform: rotate(30deg);
  }
}
@keyframes eye-close {
  90% {
    width: 16px;
    height: 0px;
    border-radius: 0%;
    border: 1px solid black;
  }
}
.l-ear {
  animation: ear-spin-left 5s ease infinite;
}
.r-ear {
  animation: ear-spin-right 5s ease infinite;
  animation-delay: 1.25s;
}
.snout {
  animation: head-spin 5s infinite;
}
.eye {
  animation: eye-close 5s linear infinite, head-spin 5s infinite;
}
.l-eye {
  left: 50px;
}
.r-eye {
  left: 120px;
}
.snout {
  left: calc(50% - 25px);
  top: 50%;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  background-color: $snout;
  &:before {
    content: ""; // position relative
  }
}
.snout-center {
  width: 100%;
  top: calc(50% - 3px);
  border: 3px solid black;
}
.nostril {
  width: 1px;
  height: 1px;
  border-radius: 50%;
  border: 5px solid black;
  top: calc(25% - 5px);
}
.l-nostril {
  left: 4px;
}
.r-nostril {
  right: 4px;
}
.cheek {
  width: 25px;
  height: 50px;
  bottom: -10px;
}
.l-cheek {
  left: -30px;
  border-top-right-radius: 58px;
  border-bottom-right-radius: 58px;
  border-left: 0;
}
.r-cheek {
  right: -30px;
  border-top-left-radius: 58px;
  border-bottom-left-radius: 58px;
  border-right: 0;
}

.leg {
  width: 75px;
  height: 100px;
  bottom: 40px;
  z-index: -5;
}
.fr-leg {
  left: 65px;
}
.fl-leg {
  right: 65px;
}
.bl-leg {
  right: 71px;
  z-index: -6;
  bottom: 50px;
}
.br-leg {
  left: 71px;
  z-index: -6;
  bottom: 50px;
}
              
            
!

JS

              
                // 🐷
              
            
!
999px

Console