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

              
                .box
  .sky
    .star
    .moon
  .head#player
    .head-copy
    .ear-left
      .inner-ear
    .ear-right
      .inner-ear
    .eye-left
       .pupil
    .eye-right
       .pupil
    .nose
    .upper-nose
    .circle
    .hair
    .mouth
    .body
button.button Move me
button.button#stopMe Stop me
     
              
            
!

CSS

              
                // colors
$pink: #6E3B7D;
$red: #B54151;
$orange: #B67CAD;
$white: #C0E0DE;
$blue: #5688C7;
$yellow: #FDD748;
$sweet-brown: #AD343E;
$rich-black: #050505;

$circle: 50%;

body {
  background: $rich-black;
}

.head {
  position: absolute;
  top: 16.5%;
  left: 25%;
  width: 50%;
  height: 67%;
  background: $pink;
  border-radius: $circle;
  animation: moveMe 13s infinite; 
}

.inner-ear {
  position: absolute;
  border-radius: 50%;
  width: 80%;
  height: 80%;
  top: -2%;
  left: 10%;
  background: $orange; 
}

.ear-left {
  position: absolute;
  border-radius: 50%;
  width: 10%;
  height: 15%;
  top: 25%;
  left: -4%;
  background: $yellow;
  z-index: 2;
}

.ear-right {
  position: absolute;
  border-radius: 50%;
  width: 10%;
  height: 15%;
  top: 30%;
  right: -5%;
  background: $yellow;
}

.eye-right {
  position: absolute;
  border-radius: 40%;
  width: 20%;
  height: 20%;
  top: 20%;
  right: 20%;
  background: $white;
}

.eye-left {
  position: absolute;
  border-radius: 40%;
  width: 20%;
  height: 20%;
  top: 20%;
  left: 20%;
  background: $white;
}

.pupil {
  position: absolute;
  border-radius: 40%;
  width: 20%;
  height: 30%;
  top: 20%;
  left: 20%;
  background: black;
}

.mouth {
  position: absolute;
  border-radius: 50%;
  width: 20%;
  height: 10%;
  bottom: 20%;
  left: 40%;
  top: 65%;
  background: $white
}

.nose {
  position: absolute;
  border-radius: 100%;
  width: 20%;
  height: 15%;
  top: 40%;
  right: 40%;
  background: $white;
  
}

.upper-nose {
  position: absolute;
  width: 20%;
  height: 15%;
  top: 30.1%;
  right: 40%;
  background: $white;
  -webkit-clip-path: polygon(100% 100%, 56% 0, 0 100%);
clip-path: polygon(100% 100%, 56% 0, 0 100%);
  z-index: 1;
}

.circle {
  position: absolute;
  width: 8%;
  height: 8%;
  top: 5.0%;
  right: 45%;
  background: $red;
  border-radius: 50%;
}

.hair {
  position: absolute;
  width: 20%;
  height: 5%;
  top: -4%;
  right: 40%;
  background: $white;
  -webkit-clip-path: polygon(100% 100%, 56% 0, 0 100%);
clip-path: polygon(100% 100%, 56% 0, 0 100%);
  z-index: 1;
}

.body {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 95.0%;
  right: 5%;
  background: $sweet-brown;
  border-radius: 50%;
  z-index: -1;
}

.star {
  position: absolute;
  top: 16.5%;
  left: 70%;
  width: 5%;
  height: 15%;
  background: $yellow;
  border-radius: $circle;
  -webkit-clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: spinMe 3s infinite; 
}

.moon {
  position: absolute;
  top: 0%;
  right: 0%;
  width: 15%;
  height: 100%;
  background: $white;
  -webkit-clip-path: circle(50% at 100% 27%);
clip-path: circle(50% at 100% 27%);
}

.moon:hover {
  animation: moveMe 3s infinite; 
}
 
// large screens
@media all and (min-width: 600px) {
  .head {
    width: 20%;
  }
}

// portrait screens
@media all and (max-height: 150px) {
  .head {
    width: 10%;
    border-radius: 50%;
  }
}

// portrait screens
@media all and (min-height: 400px) {
  .head {
    height: 30%;
  }
}

//CSS animations
//animation of spinMe
@keyFrames spinMe {
  0%{
    transform: rotate(0deg); 
  }

  100%{
    transform: rotate(360deg);
   
  }
}

@keyFrames moveMe {
  0%{
     transform: translate(0px, 0px);
  }
  100%{
     transform: translate(10px, 100px);
  }
 
}

@keyFrames stopMe {
  0%{
     transform: translate(0px, 0px);
  }
  100%{
     transform: translate(0px, 0px);
  }
 
}

.button {
  height: 50px;
  top: 0;
  width: 15%;
  text-align: center;
  background-color: #FDAD00;
}

.movePlayer {
  animation: moveMe 1s infinite; 
}

.stopPlayer {
  animation: stopMe 1s infinite; 
}


              
            
!

JS

              
                // buttons
let player = document.getElementById("player");
let moveMe = document.querySelector("button");
let stopMe = document.getElementById("stopMe");


  moveMe.addEventListener("click", () => {
 
 player.classList.add("movePlayer");
    player.className += ' movePlayer'; 
    player.classList.remove("stopMe");
    
    
    
  });


stopMe.addEventListener("click", () => {
 console.log("hi")
 stopMe.classList.add("stopMe");
    player.className += ' stopPlayer'; 
    player.classList.remove("moveMe");
    
  });


              
            
!
999px

Console