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="container">
    <div class="no-face">

      <div class="face">
        <div class="eyes-container">
          <div class="left eye-container">
            <div class="mark mark-top"></div>
            <div class="eye"></div>
            <div class="eyebag"></div>
            <div class="mark mark-bottom"></div>
          </div>
          <div class="right eye-container">
            <div class="mark mark-top"></div>
            <div class="eye"></div>
            <div class="eyebag"></div>
            <div class="mark mark-bottom"></div>
          </div>
        </div>
        <div class="mouth-container">
          <div class="mouth"></div>
          <div class="chin"></div>
        </div>
      </div>

      <div class="real-mouth">
        <div class="real-mouth-top">
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
        </div>
        <div class="real-mouth-bottom">
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
          <div class="teeth"></div>
        </div>
      </div>

      <div class="end">
      </div>

    </div>
    <div class="bird-and-mouse">
      <div class="bird">
        <div class="eyes-container">
          <div class="left eye"></div>
          <div class="right eye"></div>
        </div>
        <div class="beak-container">
          <div class="left prepart"></div>
          <div class="right prepart"></div>
          <div class="left part"></div>
          <div class="right part"></div>
        </div>
        <div class="legs-container">
          <div class="left leg"></div>
          <div class="right leg"></div>
        </div>
        <div class="left wing"></div>
        <div class="right wing"></div>
      </div>
      <div class="mouse">
        <div class="head-container">
          <div class="left ear"></div>
          <div class="head-top"></div>
          <div class="right ear"></div>
          <div class="cheek-container">
            <div class="left cheek"></div>
            <div class="right cheek"></div>
          </div>
        </div>
        <div class="face">
          <div class="eyes-container">
            <div class="left eye"></div>
            <div class="right eye"></div>
          </div>
          <div class="nose"></div>
        </div>
        <div class="body-container">
          <div class="hands-container">
            <div class="left hand"></div>
            <div class="right hand"></div>
          </div>
          <div class="body"></div>
        </div>
      </div>
    </div>
    <div class="shadow"></div>
  </div>

<div class="created">
  <span>Created by</span>
  <a href="https://manz.dev/"><h2>Manz.dev</h2></a>
  <p>on <a href="https://twitch.tv/ManzDev">Twitch</a> / <a href="https://youtu.be/JGOQk6cqBaE">Youtube</a></p>
</div>
              
            
!

CSS

              
                @use postcss-nested;

:root {
  --no-face-color: #222;
  --no-face-gradient: linear-gradient(to bottom, #222 40%, #222e 60%, #2229 80%, transparent 100%);
  --no-face-shadow: #888;
  --no-face-width: 175px;
  --no-face-height: 400px;
  --mark-color: #876f83;
  --mouse-color: #cfbab5;
  --mouse-shadow: #b9a6a2;
  --custom-filter: drop-shadow(2px 0 0 var(--mouse-shadow)) drop-shadow(0 2px 0 var(--mouse-shadow)) drop-shadow(-2px 0 0 var(--mouse-shadow)) drop-shadow(0 -2px 0 var(--mouse-shadow));
}

.container {
  display: flex;
  justify-content: center;
  margin-top: 2em;
}

.no-face {
  background: var(--no-face-gradient);
  width: var(--no-face-width);
  height: var(--no-face-height);
  border-radius: 45% 45% 0 0 / 20% 20% 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  filter: drop-shadow(0 0 2px #5f3399) drop-shadow(0 0 5px #391469) drop-shadow(0 0 15px #270850);

  & .face {
    width: 125px;
    height: 175px;
    margin-top: 20px;
    border-radius: 50% 50% 44% 44% / 30% 30% 44% 44%;
    background: #fff;

    & .eyes-container {
      width: 110px;
      height: 110px;
      margin: auto;
      display: flex;
      justify-content: space-between;

      & .eye-container {
        width: 45px;
        height: 90px;
        transform: translateY(20px);
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;

        &.right {
          transform: translateY(20px) scaleX(-1);
        }

        & .mark {
          background: var(--mark-color);
        }

        & .mark-top {
          width: 10px;
          height: 22px;
          border-radius: 100% 100% 40% 40% / 200% 200% 25% 25%;
          transform: translateX(5px);
        }

        & .eye {
          width: 30px;
          height: 11px;
          background: var(--no-face-color);
          border-radius: 50%;
        }

        & .eyebag {
          width: 30px;
          height: 11px;
          background: var(--no-face-shadow);
          border-radius: 50%;
          clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
        }

        & .mark-bottom {
          width: 18px;
          height: 35px;
          border-radius: 50% 50% 100% 100% / 45% 45% 150% 150%;
        }
      }
    }

    & .mouth-container {
      width: 100px;
      height: 40px;
      margin: auto;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      align-items: center;

      & .mouth {
        width: 55px;
        height: 22px;
        background: var(--no-face-color);
        border-radius: 50%;
        clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
      }

      & .chin {
        width: 25px;
        height: 8px;
        background: var(--no-face-shadow);
        border-radius: 50%;
        clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
      }
    }
  }

  & .real-mouth {
    background: darkred;
    width: 175px;
    display: block;
    height: 0;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;

    &.bite {
      display: flex;
      animation: moveMouth 0.15s ease-out infinite alternate-reverse;
    }

    &.opened {
      display: flex;
      height: 123px;
    }

    & .real-mouth-top,
    & .real-mouth-bottom {
      display: flex;
    }

    & .teeth {
      width: 25px;
      height: 30px;
      background: #fff;
    }

    & .real-mouth-top .teeth {
      border-top: 6px solid red;
      border-radius: 0 0 50% 50% / 0 0 40% 40%;
    }

    & .real-mouth-bottom .teeth {
      border-bottom: 6px solid red;
      border-radius: 50% 50% 0 0 / 40% 40% 0 0;
    }
  }

  & .end {
    width: 100%;
    height: 50px;
  }
}

@keyframes moveMouth {
  0% {
    height: 73px;
  }

  100% {
    height: 123px;
  }
}

.mouse {
  width: 110px;
  height: 135px;
  transform: translateY(50px);

  & .head-container {
    width: 75px;
    height: 75px;
    margin: auto;
    filter: var(--custom-filter);
    position: relative;
    z-index: 5;

    & .ear {
      position: absolute;
      width: 15px;
      height: 30px;
      background: #82627c;
      border-radius: 50% 0 0 50% / 70% 0 0 20%;

      &.left {
        transform: translate(10px, -5px) rotate(-25deg);
      }

      &.right {
        transform: translate(50px, -65px) rotate(25deg) scaleX(-1);
      }
    }

    & .head-top {
      width: 60px;
      height: 60px;
      margin: auto;
      border-radius: 50%;
      background: var(--mouse-color);
      position: relative;
      z-index: 2;
      transform: translateY(3px);
    }

    & .cheek-container {
      display: flex;
      transform: translate(0, -2px);
    }

    & .cheek {
      position: absolute;
      display: inline-block;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: var(--mouse-color);

      &.left {
        transform: translate(0, -25px);
      }

      &.right {
        transform: translate(35px, -25px);
      }
    }
  }

  & .face {
    position: absolute;
    z-index: 5;
    width: 45px;
    transform: translate(32px, -50px);
    display: flex;
    flex-direction: column;
    align-items: center;

    & .eyes-container {
      width: 100%;
      display: flex;
      justify-content: space-between;
    }

    & .eye {
      background: #fff;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      display: flex;
      justify-content: center;

      &::after {
        content: "";
        display: block;
        background: #111;
        border-radius: 50%;
        width: 8px;
        height: 8px;
        transform: translateY(1px);
      }
    }

    & .nose {
      width: 6px;
      height: 6px;
      background: #604552;
      border-radius: 50%;
    }
  }

  & .body-container {
    width: 100px;
    height: 70px;
    background: var(--mouse-color);
    border: 2px solid var(--mouse-shadow);
    border-radius: 30% 30% 50px 50px / 100px 100px 20px 20px;
    transform: translate(5px, -10px) rotateX(15deg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;

    & .hands-container {
      width: 35px;
      height: 25px;
      display: flex;
      justify-content: space-between;
      position: absolute;
      transform: translateY(14px);

      & .hand {
        display: flex;

        &::before,
        &::after {
          content: "";
          display: block;
          width: 2px;
          height: 100%;
          background: var(--mouse-shadow);
        }

        &::after {
          transform: translate(-11px, 2px) rotate(-45deg);
        }

        &.right {
          transform: scaleX(-1);
        }
      }
    }

    & .body {
      background: #fff;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      transform: translateY(35px);
    }
  }
}

.bird-and-mouse {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: flyLittleFriends 1.25s ease infinite alternate;
}

.bird {
  position: absolute;
  background: #222;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  transform: translateY(-10px);
  display: flex;
  flex-direction: column;
  align-items: center;

  & .eyes-container {
    display: flex;
    width: 100%;
    justify-content: space-evenly;
    align-items: center;
    transform: translate(0, 14px);

    & .eye {
      background: #fff;
      border-radius: 50%;
      width: 12px;
      height: 12px;
      display: flex;
      justify-content: center;
      align-items: center;

      &::before {
        content: "";
        display: block;
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: #111;
        transform: translate(1px, -1px);
      }
    }
  }

  & .beak-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 0.5fr 1.5fr;
    width: 30px;
    height: 35px;
    transform: translate(0, 10px);

    & .prepart,
    & .part {
      background: #fcac4d;
      border-bottom: 1px solid #fcac4d;
    }

    & .prepart {
      clip-path: polygon(100% 0, 100% 100%, 0 100%);
      transform: translateY(1px);

      &.right {
        transform: translate(-1px, 1px) scaleX(-1);
      }
    }

    & .part {
      clip-path: polygon(0 0, 100% 0, 100% 100%);

      &.right {
        transform: translateX(-1px) scaleX(-1);
      }
    }
  }

  & .legs-container {
    display: flex;

    & .leg {
      position: absolute;
      height: 30px;
      border-left: 3px solid #111;
      z-index: -1;

      &.left {
        transform: translate(-11px, -10px) rotate(-20deg);
      }

      &.right {
        transform: translate(7px, -10px) rotate(20deg);
      }
    }
  }

  & .wing {
    width: 24px;
    height: 8px;
    border-radius: 45%;
    background: #111;
    position: absolute;
    top: 18px;

    &.left {
      left: -27px;
      animation: moveWings 0.15s linear infinite;
    }

    &.right {
      left: 48px;
      animation: moveWingsRight 0.15s linear infinite;
    }
  }
}

@keyframes flyLittleFriends {
  0% {
    transform: translate(20px, 0);
  }

  100% {
    transform: translate(20px, 20px);
  }
}

@keyframes moveWings {

  0%,
  100% {
    transform: translateY(-25px) rotate(55deg);
  }

  33% {
    transform: translateY(0) rotate(0deg);
  }

  66% {
    transform: translateY(25px) rotate(-55deg);
  }
}

@keyframes moveWingsRight {

  0%,
  100% {
    transform: translateY(-25px) rotate(-55deg);
  }

  33% {
    transform: translateY(0) rotate(0deg);
  }

  66% {
    transform: translateY(25px) rotate(55deg);
  }
}

.shadow {
  background: rgba(0, 0, 0, 0.3);
  width: 65px;
  height: 15px;
  filter: blur(2px);
  border-radius: 50%;
  position: absolute;
  top: 520px;
  animation: animatedShadow 1.25s ease infinite alternate;
}

@keyframes animatedShadow {
  0% {
    transform: translate(115px, -85px) scale(0.8);
  }

  100% {
    transform: translate(115px, -85px) scale(1);
  }
}

.created {
  background: 
    url(https://assets.codepen.io/154065/internal/avatars/users/default.png),
    linear-gradient(to bottom, #884ced, #ec1cce);
  background-size: 75px 75px, cover;
  background-repeat: no-repeat;
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  height: 75px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 2em;
  
  & span,
  & h2,
  & p,
  & a {
    font-family: Montserrat;
    margin: 0;
  }
  
  & a,
  & p,
  & span {
    color: #fff;    
  }
  
  & h2 {
    font-weight: 700;
    transform: translate(0, -4px);    
  }
  
  & a {
    text-decoration-color: rgba(255,255,255,0.4);
  }
  
  & a:hover {
    color: #e6e82a;
  }
}
              
            
!

JS

              
                const WAIT_TIME = 30000;
const realMouth = document.querySelector(".real-mouth");

const enableBite = () => {
  realMouth.classList.add("bite");
  const timeToEnd = (Math.floor(Math.random() * 5) * 1000) + 3000;
  const timeToStart = (Math.floor(Math.random() * 5) * 1000) + WAIT_TIME;
  setTimeout(() => disableBite(), timeToEnd);
  setTimeout(() => enableBite(), timeToEnd + 10000 + timeToStart);
};
const disableBite = () => realMouth.classList.remove("bite");

const timeToStart = (~~(Math.random() * 5) * 1000) + 3000;

setTimeout(() => enableBite(), timeToStart);
              
            
!
999px

Console