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

              
                <svg class="sad" width="44px" height="44px" viewBox="0 0 44 44" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="sad" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(0, 0)">
        <circle id="body" fill="#E23D18" cx="22" cy="22" r="22"></circle>
        <g id="face" transform="translate(13.000000, 20.000000)">
            <g class="face">
            <path d="M7,4 C7,5.1045695 7.8954305,6 9,6 C10.1045695,6 11,5.1045695 11,4" class="mouth" stroke="#2C0E0F" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" transform="translate(9.000000, 5.000000) rotate(-180.000000) translate(-9.000000, -5.000000) "></path>
            <ellipse class="right-eye" fill="#2C0E0F" cx="16.0941176" cy="1.75609756" rx="1.90588235" ry="1.75609756"></ellipse>
            <ellipse class="left-eye" fill="#2C0E0F" cx="1.90588235" cy="1.75609756" rx="1.90588235" ry="1.75609756"></ellipse>
          </g>
        </g>
    </g>
</svg>
  
 <svg class="neutral" width="44px" height="44px" viewBox="0 0 44 44" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g>
        <circle id="body" fill="#F9AC1B" cx="22" cy="22" r="22"></circle>
        <g class="face">
          <g transform="translate(13.000000, 20.000000)" fill="#2C0E0F">
            <g class="mouth">
                <g transform="translate(9, 5)" >
                  <rect x="-2" y="0" width="4" height="2" rx="2"></rect>
                </g>
              </g>
              <ellipse class="right-eye" cx="16.0941176" cy="1.75" rx="1.90588235" ry="1.75"></ellipse>
              <ellipse class="left-eye" cx="1.90588235" cy="1.75" rx="1.90588235" ry="1.75"></ellipse>
          </g>
        </g>
    </g>
</svg>

<svg class="fine" width="44px" height="44px" viewBox="0 0 44 44" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="fine-emotion" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="fine">
            <circle id="body" fill="#1988E3" cx="22" cy="22" r="22"></circle>
            <g class="matrix" transform="translate(22.000000, 32.000000)">
             <g class="face-container">
              <g class="face" transform="translate(-9, -12)">
                <g class="face-upAndDown">
                <g class="eyes">
                <ellipse class="right-eye" fill="#2C0E0F" cx="16.0941176" cy="1.75609756" rx="1.90588235" ry="1.75609756"></ellipse>
                <ellipse class="left-eye" fill="#2C0E0F" cx="1.90588235" cy="1.75609756" rx="1.90588235" ry="1.75609756"></ellipse></g>
                <path d="M6.18823529,4.90499997 C6.18823529,5.95249999 7.48721095,7 9.08957864,7 C10.6919463,7 11.990922,5.95249999 11.990922,4.90499997" id="mouth" stroke="#2C0E0F" stroke-linecap="round" stroke-linejoin="round"></path>
                </g>
            </g>
            </g>
          </g>
        </g>
    </g>
</svg>

<svg class="happy" width="44px" height="44px" viewBox="0 0 44 44" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <g id="Happy" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(0, 0)">
          <circle id="Body" fill="#248C37" cx="22" cy="22" r="22"></circle>
        <g class="scaleFace">
          <g class="face">  
            <ellipse id="Eye-right" fill="#2C0E0F" cx="29.0875" cy="21.75" rx="1.89926471" ry="1.75"></ellipse>
              <ellipse id="Eye-left" fill="#2C0E0F" cx="14.8992647" cy="21.75" rx="1.89926471" ry="1.75"></ellipse>
              <path d="M21.8941176,27.8819633 C24.8588235,27.8819632 25.4941176,25.5404999 25.4941176,24.5648901 C25.4941176,23.5892803 24.4352941,23.9795242 22.1058824,23.9795242 C19.7764706,23.9795242 18.2941176,23.5892803 18.2941176,24.5648901 C18.2941176,25.5404999 18.9294118,27.8819633 21.8941176,27.8819633 Z" id="Mouth" fill="#2C0E0F"></path>
              <ellipse id="Tung" fill="#E23D18" cx="21.8941176" cy="26.4390244" rx="1.69411765" ry="0.780487805"></ellipse>
          </g>  
      </g>
  </svg>
  
  



              
            
!

CSS

              
                @use postcss-nested;
@use postcss-simple-vars;

html, body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

svg {
  margin: 10px;
  width: 10em;
  height: 10em;
}

svg.happy {

  .face {
    animation: upAndDown 0.8s ease infinite;  
  }
  
  .scaleFace {
    transform-origin: 35px 20px;
    transform: rotate(12deg);
  }

}

svg.sad {
  width: 10em;
  height: 10em;
  
  .face {
    animation: leftToRight 0.4s linear infinite alternate-reverse;
  }
  
  .left-eye, .right-eye {
    opacity: 1;
    transform-origin: 0 1px;
    animation: 
      blink 3s linear infinite,
      blinkSqueeze 3s linear infinite;
  }
  
  .mouth {
    padding-top: 20px;
  }
}

svg.neutral {
  .face {
    animation: upAndDown 6s ease infinite; 
  }
  
  .left-eye, .right-eye {
    opacity: 1;
    transform-origin: 0 1px;
    animation: 
      blink 3s linear infinite,
      blinkSqueezeTwice 3s linear infinite;
    animation-delay: 1s;
  }
  .mouth {
    animation: scaleX 2s ease infinite alternate-reverse;
  }
}

svg.fine {
  .face-container {
    animation: rotateLeftToRight 3s infinite;
  }
  
  .face-upAndDown {
    animation: fineUpAndDown 3s infinite;
  }
  
  .left-eye, .right-eye {
    opacity: 1;
    transform-origin: 0 1px;
    animation: 
      blink 3s linear infinite,
      blinkSqueeze 3s linear infinite;
  }
}

@keyframes rotateLeftToRight {
  0% { transform: rotate(15deg); }
  50% { transform: rotate(-15deg); }
  100% { transform: rotate(15deg); }
}

@keyframes fineUpAndDown {
  0% { transform: translate(0, 0); }
  25% { transform: translate(0, -1px); }
  50% { transform: translate(0, 0); }
  75% { transform: translate(0, -1px); }
  100% { transform: translate(0, 0); }
}

@keyframes upAndDown {
  0% { transform: translate(0, -1px); }
  50% { transform: translate(0, 2px); }
  100% { transform: translate(0, -1px); }
}

@keyframes leftToRight {
  0% { transform: translate(-1px, 4px); }
  100% { transform: translate(1px, 4px); }
}

@keyframes leftToRightWide {
  0% { transform: translate(-5px, 1px); }
  100% { transform: translate(2px, 1px); }
}

@keyframes scaleX {
  0% { transform: translate(0, 0) scale(1, 1); }
  100% { transform: translate(-9px, 0) scale(2, 1); }
}

@keyframes scaleUpAndDown {
  0% { transform: scale(1, 1); }
  100% { transform: scale(1, 1.2); }
}

@keyframes blink {
  0% { opacity: 1; }
  45% { opacity: 1; }
  50% { opacity: 0; }
  55% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes blinkSqueeze {
  0% { transform: scale(1, 1); }
  45% { transform: scale(1, 1); }
  50% { transform: scale(1, 0); }
  55% { transform: scale(1, 1); }
  100% { transform: scale(1, 1); }
}

@keyframes blinkSqueezeTwice {
  0% { transform: scale(1, 1); }
  45% { transform: scale(1, 1); }
  50% { transform: scale(1, 0); }
  55% { transform: scale(1, 1); }
  60% { transform: scale(1, 0); }
  65% { transform: scale(1, 1); }
  100% { transform: scale(1, 1); }
}
              
            
!

JS

              
                
              
            
!
999px

Console