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="heartContainer">
    <div class="overlay">
    </div>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="heartStroke" x="0px" y="0px" viewBox="0 0 52 52" style="enable-background:new 0 0 52 52;" xml:space="preserve">
    <path fill="#fff"d="M51.911,16.242C51.152,7.888,45.239,1.827,37.839,1.827c-4.93,0-9.444,2.653-11.984,6.905   c-2.517-4.307-6.846-6.906-11.697-6.906c-7.399,0-13.313,6.061-14.071,14.415c-0.06,0.369-0.306,2.311,0.442,5.478   c1.078,4.568,3.568,8.723,7.199,12.013l18.115,16.439l18.426-16.438c3.631-3.291,6.121-7.445,7.199-12.014   C52.216,18.553,51.97,16.611,51.911,16.242z M49.521,21.261c-0.984,4.172-3.265,7.973-6.59,10.985L25.855,47.481L9.072,32.25   c-3.331-3.018-5.611-6.818-6.596-10.99c-0.708-2.997-0.417-4.69-0.416-4.701l0.015-0.101C2.725,9.139,7.806,3.826,14.158,3.826   c4.687,0,8.813,2.88,10.771,7.515l0.921,2.183l0.921-2.183c1.927-4.564,6.271-7.514,11.069-7.514   c6.351,0,11.433,5.313,12.096,12.727C49.938,16.57,50.229,18.264,49.521,21.261z"/>
    </svg>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="heart" x="0px" y="0px" viewBox="-1 -1 52 52" style="enable-background:new 0 0 52 52;" xml:space="preserve">
    <path class="color" style="fill:#D75A4A;" d="M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223,0,12.425,6.179,13.079,13.543  c0,0,0.353,1.828-0.424,5.119c-1.058,4.482-3.545,8.464-6.898,11.503L24.85,48L7.402,32.165c-3.353-3.038-5.84-7.021-6.898-11.503  c-0.777-3.291-0.424-5.119-0.424-5.119C0.734,8.179,5.936,2,13.159,2C18.522,2,22.832,5.343,24.85,10.126z"/>
    </svg>
  </div>
</div>

              
            
!

CSS

              
                html, body {
  background: #fefefe;
}
.heartContainer {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.overlay {
  position: absolute;
  width: 200px;
  height: 200px;
  background: #fefefe;
  z-index: 1001;
}
.heart, .heartStroke {
  width: 200px;
  height: auto;
  position: absolute;
}
.heart {
  z-index: 1000;
}
.heartStroke {
  z-index: 1002;
  filter: drop-shadow(5px -5px 10px #000);
}

@keyframes fill {
  0% {
    transform: translateY(0px);
  }
  33% {
    transform: translateY(0px);
  }
  66% {
    transform: translateY(-500px);
  }
  100% {
    transform: translateY(-500px);
  }
}

              
            
!

JS

              
                // The following exercises will test your knowledge of JavaScript variables and data types. 
// Perform an exercise correctly and you will see a new animation
// Perform an exercise incorrectly and the page will turn black. Correct your mistake in your code to revert the black page of death.
// You don't need to pay attention to or understand the code at the bottom just yet.

//1 : Declare a true boolean variable named 'love'. 
  // If done correctly, the heart will be filled with red.
//2 : Declare a variable named color that stores the string purple.
  // If done correctly, the heart will be filled with purple.
//3: Declare an array named colorArray that stores the colors of the rainbow in the correct order(ROYGBIV) and in lowercase (ex: red, orange..)
  // If done correctly, the background will change to a rainbow picture









fillUpHeart = document.querySelector(".overlay");
backGround = document.querySelector(".heartContainer");
changeColor = document.querySelector(".color");
if (love){
  fillUpHeart.style.cssText = "animation : fill 6s ease forwards;";
}else{
  backGround.style.cssText = "background : black;";
  fillUpHeart.style.background = "black";
}

if(color=="purple"){
  changeColor.style.cssText = "fill:#8933FF;";
}
else{
  backGround.style.cssText = "background : black;";
  fillUpHeart.style.background = "black";
}

let correctArray = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"];
let checker;
for(i = 0; i < colorArray.length; i++){
  if(colorArray[i] == correctArray[i]){
   checker = true;
  }
  else{
   checker = false;
  }
}
if(checker){
   backGround.style.cssText = "background-image : url('https://i.pinimg.com/originals/2d/2a/f3/2d2af390cd719bdf850689b310ee8a39.jpg');";
}
else{
  backGround.style.cssText = "background : blue;";
}



              
            
!
999px

Console