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

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

              
                // Author: Ali Soueidan
// Author URI: https//: www.alisoueidan.com

- var slices = 0;

ul.happy#head

    li.slice

        .hair

        .folds#fold-1

        .folds#fold-2

    li.slice

        .ears#ear-l

        .ears#ear-r

        .eyes#eye-l
            .eyelid

        .eyes#eye-r
            .eyelid

    li.slice

        .nose
            .hole
            .hole

    li.slice

        .mouth

            .teeth.top
                .tooth
                .tooth
                .tooth
                .tooth
                .tooth

            .teeth.bottom
                .tooth
                .tooth
                .tooth
                .tooth
                .tooth

.corpus

    .belly

    .chain

ul#nav 
    li.happy#selected 😃
    li.astonished 😲
    li.feared 😱
    li.anguished  😧
    li.angry 😡
    li.tired 😪
    li.ondrugs 🎁

a( href='http://bit.ly/2JPuBjx' target="_blank" class='reference' ) 🔗 Ali Soueidan
              
            
!

CSS

              
                // Author: Ali Soueidan
// Author URI: https//: www.alisoueidan.com

*
  list-style: none
  margin: 0
  padding: 0

$gap: 2vh
$shadow: hsla(0, 0%, 0%, 0.25)
$skin: hsla(169, 100%, 25%, 1)
$skin2: hsla(169, 100%, 20%, 1)
$hair: hsl(0, 100%, 60%)
$mouth: hsla(200, 100%, 25%, 1)
$eyes: hsla(40, 100%, 60%, 1)
$eye-accent-1: hsla(280, 100%, 25%, 1)
$bg: rgba(50,50,100,1)

.reference
  position: absolute
  right: 24px 
  bottom: 24px
  padding: $gap
  color: #fff
  font-family: arial
  text-decoration: none
  background: $bg
  box-shadow: 0 0 $gap $shadow
  border-radius: $gap

body 
  display: flex 
  flex-direction: column
  justify-content: center 
  align-items: center
  margin: 0
  height: 100vh
  background: #fff

ul#nav
  position: absolute
  transform: translateX(-100%)
  top: 0
  left: 0
  bottom: 0
  display: flex
  flex-direction: column
  justify-content: space-around
  align-items: center
  padding: $gap*1.5
  background: $bg
  box-shadow: inset 0 0 $gap/4 $shadow
  transition: .8s ease
  li
    display: flex
    justify-content: center
    align-items: center
    width: $gap*3
    max-width: $gap*3
    height: $gap*3
    max-height: $gap*3
    box-shadow: 0 0 $gap/4 $shadow
    border-radius: $gap/2
    transition: .2s ease
    background: #efefef
    font-size: $gap*1.5
    &#selected
      transform: scale(1.2)
      background: #fff
      &:hover
        transform: scale(1.2)
    &:hover
      cursor: pointer
      transform: scale(1.1)
      background: #fff

.corpus 
  position: absolute
  z-index: -1
  bottom: 0
  width: $gap*40
  height: 50vh
  background: radial-gradient($skin,$skin2)
  border-radius: $gap*20 $gap*20 0 0
  filter: drop-shadow($gap/2 $gap/2 $gap rgba(0,0,50,.5))
  box-shadow: inset $gap $gap $gap rgba(0,0,50,.1)

  .chain
    position: absolute
    top: 0% 
    left: 50% 
    transform: translate(-50%, -40%)
    width: $gap*15
    height: 50vh
    border: $gap solid $eyes
    border-radius: 50%
    filter: drop-shadow(0 0 $gap rgba(0,0,50,.05))
    box-shadow: inset $gap $gap $gap rgba(0,0,50,.1)

  .belly 
    position: absolute
    bottom: 0
    left: 50% 
    transform: translateX(-50%)
    width: $gap*20
    height: $gap*10
    border-right: $gap solid $shadow
    border-left: $gap solid $shadow
    border-radius: $gap*10 $gap*10 0 0
    filter: drop-shadow($gap $gap $gap rgba(0,0,50,.5))
    box-shadow: inset $gap $gap $gap rgba(0,0,50,.1)

#head
  position: relative
  display: flex
  flex-direction: column
  justify-content: space-between
  margin-bottom: $gap*8
  width: $gap*20
  height: $gap*30
  background: $skin
  border-radius: $gap*10
  filter: drop-shadow($gap/2 $gap/2 $gap*2 rgba(0,0,50,.5))
  box-shadow: inset $gap $gap $gap rgba(0,0,50,.1)
  transition: .8s ease

  li.slice 
    width: 100%
    height: $gap*5

    &:first-child
      position: relative
      display: flex
      flex-direction: column
      justify-content: center
      align-items: center
      border-radius: $gap*10 $gap*10 0 0
      height: $gap*10

      .hair
        position: absolute 
        top: -$gap
        left: 50%
        transform: translate(-50%,-50%)
        background: $hair
        width: $gap*3
        height: $gap*4
        border-radius: 50%
        clip-path: polygon(50% 50%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)
       
      .folds
        height: $gap/2
        background: $shadow
        border-radius: $gap

      #fold-1
        margin-bottom: $gap
        width: 50%

      #fold-2
        width: 25%
    
    &:nth-child(2)
      position: relative
      display: flex
      justify-content: space-around 
      align-items: center

      .eyebrows
        position: absolute
        background: red
        width: $gap*10
        height: $gap*10
        transform: rotate(45deg)

      .ears
        position: absolute
        top: 0
        height: $gap*5
        width: $gap*2
        transition: .8s ease
        box-shadow: inset 0 0 $gap rgba(0,0,50,.5)
        &:before 
          position: absolute
          top: 50%
          left: 50%
          transform: translate(-50%,-50%)
          content: ""
          width: $gap/2
          height: $gap*3

        &#ear-l
          left: 0
          transform: translateX(-100%)
          border-right:  $gap/4 solid $shadow
          border-radius: $gap*2.5 $gap*2.5 $gap*2.5 $gap*5
          background: $skin
          &:before 
            border: $gap/4 solid $shadow
            border-right: 1px solid $shadow
            border-radius: $gap*2.5 $gap*2.5 $gap*2.5 $gap*5

        &#ear-r
          right: 0
          transform: translateX(100%)
          border-left: $gap/4 solid $shadow
          border-radius: $gap*2.5 $gap*2.5 $gap*5 $gap*2.5
          background: $skin
          &:before 
            border: $gap/4 solid $shadow
            border-left: 1px solid $shadow
            border-radius: $gap*2.5 $gap*2.5 $gap*5 $gap*2.5

      .eyes
        position: relative
        z-index: 1
        display: flex
        justify-content: center 
        align-items: center
        height: $gap*5
        width: $gap*5
        background: $eyes
        border: $gap/4 solid $shadow
        border-radius: 50%
        transition: 1s ease
        overflow: hidden
        transition: .8s ease
        &:before 
          content: ""
          height: $gap*2
          width: $gap*2
          background: #000
          border-radius: 50%
          border: $gap/4 solid $eye-accent-1
          transition: .8s ease
          filter: drop-shadow(0 0 $gap/8 $eye-accent-1)
          box-shadow: inset 0 0 $gap/2 rgba(50,50,75,1)
        &:after 
          content: ""
          position: absolute
          top: 35%
          right: 35%
          height: $gap/2
          width: $gap/2
          background: rgba(255,255,255,1)
          border-radius: 50%
          filter: drop-shadow(0 0 $gap/8 rgba(200,200,200,1))
          box-shadow: inset 0 0 $gap/2 rgba(120,120,120,.25)

        .eyelid
          position: absolute 
          transform: translateY(-100%)
          width: $gap*20
          height: $gap*20
          background: radial-gradient($skin,$skin2)
          transition: .8s ease
    
    &:nth-child(3)
      position: relative
      display: flex
      justify-content: center
      align-items: center

      .nose 
        display: flex
        justify-content: space-around
        align-items: center
        height: $gap*5
        width: $gap*5
        border-top: $gap/2 solid $shadow
        border-radius: 50%
        transition: .8s ease
        filter: drop-shadow(0 $gap/2 $gap/2 rgba(0,0,0,1))
        .hole 
          transform: translateY(-100%)
          width: $gap
          height: $gap
          background: $shadow
          border-radius: 50%

    &:last-child
      display: flex
      justify-content: center
      align-items: center
      border-radius: 0 0 $gap*10 $gap*10
      height: $gap*10

      .mouth 
        display: flex
        flex-direction: column
        justify-content: space-between
        align-items: center
        width: $gap*12
        height: $gap*6
        background: $mouth
        border-radius: $gap $gap $gap*6 $gap*6
        border: $gap/2 solid $shadow
        overflow: hidden
        transition: .8s ease
        filter: drop-shadow(0 0 $gap rgba(0,0,50,.2))
        box-shadow: inset 0 0 $gap*4 rgba(0,0,0,.75)

        .teeth 
          display: flex
          justify-content: space-around
          width: 100%
          height: $gap 

          &.top

            .tooth
              width: 22%
              height: $gap
              background: #fff
              border-right: $gap/10 solid $shadow
              border-bottom: $gap/10 solid $shadow
              border-left: $gap/10 solid $shadow
              border-radius: $gap/4 $gap/4 $gap/2 $gap/2
              filter: drop-shadow(0 0 $gap rgba(0,0,0,.2))
              box-shadow: inset 0 0 $gap rgba(200,200,200,.25)

          &.bottom

            .tooth
              width: 22%
              height: $gap
              border: $gap/10 solid $shadow
              background: #fff
              border-radius: $gap/2 $gap/2 $gap/4 $gap/4
              filter: drop-shadow(0 0 $gap rgba(0,0,0,.2))
              box-shadow: inset 0 0 $gap rgba(200,200,200,.25)






  &.happy
      
      .eyes
        transform: scale(1)

        &#eye-l
          &:before
            transform: scale(1.33)

        &#eye-r
          &:before
            transform: scale(1.33)






  &.Astonished
    transform: translateY(-$gap*2)

    &:first-child
      
      .eyes
        transform: scale(.75)

    .slice:last-child 
      
      .mouth 
        border-radius: $gap*6 $gap*6 $gap $gap
        transform: scale(.75) rotate(-5deg)






  &.feared

    &:nth-child(1)
      
      .eyes
        transform: scale(1.25)

    .slice:last-child 
      
      .mouth 
        height: $gap*8
        border-radius: $gap*6 $gap*6 $gap*4 $gap*4






  &.angry
    transform: translateY(-$gap*2) rotate(-5deg)

    &:first-child

      .ears
        width: $gap*1.25!important
      
      .eyes
        transform: scale(1)

        &#eye-l
          clip-path: polygon(30% 0%, 61% 11%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)
          &:before
            transform: scale(.75)
            border: $gap solid $eye-accent-1

        &#eye-r
          clip-path: polygon(34% 14%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)
          &:before
            transform: scale(.75)
            border: $gap solid $eye-accent-1

    &:nth-child(1)
      
      .nose 
        transform: scale(1.2)

    .slice:last-child 
      
      .mouth 
        transform: rotate(4deg)
        height: $gap*2
        border-radius: $gap*6 $gap*6 $gap*4 $gap*4






  &.anguished
    transform: translateY(-$gap*2) rotate(5deg)

    &:nth-child(1)

      .eyes 
        border: $gap/4 solid $skin!important
        transform: scale(1)

      #eye-l
        transform: scale(1.25)
        .eyelid
          transform: translateY(-62.5%) rotate(-23deg) 
          &:before
            transform: scale(.75)

      #eye-r
        transform: scale(.75)
        .eyelid
          transform: translateY(-62.5%) rotate(23deg) 
          &:before
            transform: scale(.75)

    .slice:last-child 
      
      .mouth 
        height: $gap*6
        border-radius: $gap*2 $gap*2 $gap*6 $gap*6
        transform: rotate(-5deg)






  &.tired
    transform: translateY($gap*4)

    &:first-child

      .ears
        width: $gap*1.75!important

        &#ear-l
          border-radius: $gap*5 $gap*2.5 $gap*2.5 $gap*2.5!important
          &:before 
            border-radius: $gap*5 $gap*2.5 $gap*2.5 $gap*2.5!important

        &#ear-r
          border-radius: $gap*2.5 $gap*5 $gap*2.5 $gap*2.5!important
          &:before 
            border-radius: $gap*2.5 $gap*5 $gap*2.5 $gap*2.5!important

      .eyes 
        border: $gap/4 solid $skin!important
        transform: scale(.75)
        .eyelid
          z-index: 1
          border-bottom: $gap/2 solid $shadow
          border-radius: 50%

      #eye-l .eyelid
        transform: translateY(-49%)

      #eye-r .eyelid
        transform: translateY(-52%)

    .slice:last-child 
      
      .mouth 
        height: $gap*8
        border-radius: $gap*2 $gap*2 $gap*6 $gap*6
        transform: rotate(-5deg)





  &.ondrugs
    transform: translateY(-$gap*2)

    &:nth-child(1)
      
      .eyes
        transform: scale(1.25)

        &#eye-l
          &:before
            transform: scale(1.75)
            border: $gap/6 solid $eye-accent-1

        &#eye-r
          &:before
            transform: scale(1.75)
            border: $gap/6 solid $eye-accent-1

    &:nth-child(1)
      
      .nose 
        transform: scale(.75)

    .slice:last-child 
      
      .mouth 
        height: $gap*8
        border-radius: $gap*2 $gap*2 $gap*6 $gap*6
              
            
!

JS

              
                // Author: Ali Soueidan
// Author URI: https//: www.alisoueidan.com

let target = document.querySelector("#head");
let emotion = document.querySelectorAll("#nav li");
let menu = document.querySelector("#nav");

let i = 0;
emotion.forEach( function() { 
    emotion[i].addEventListener("click", function() {
        clearInterval(walkThrough);
        target.removeAttribute("class");
        target.classList.add(this.classList[0]);
        let i = 0;
        emotion.forEach( function() { 
            emotion[i].removeAttribute("id", "selected");
            ++i;
        });
        this.setAttribute("id", "selected");
    });
    ++i;
});

// Walkthrough emotions on start (sparing the last one for better thumbnail)
let n = 1;
let walkThrough = setInterval(() => {
    target.removeAttribute("class");
    target.classList.add(emotion[n].classList[0]);
    ++n;
    if ( n == emotion.length ) {
        target.removeAttribute("class");
        target.classList.add(emotion[0].classList[0]);
        setTimeout(() => {
            menu.style.transform = "translateX(0)";
        }, 1000);
        clearInterval(walkThrough);
    }
}, 1250);
              
            
!
999px

Console