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="lovely-wrapper">
  <svg class="lovely-heart" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 198 162">
    <g>
      <polygon class="background-heart" points="180 18 180 0 162 0 144 0 126 0 126 18 108 18 108 36 90 36 90 18 72 18 72 0 54 0 36 0 18 0 18 18 0 18 0 36 0 54 0 72 18 72 18 90 36 90 36 108 54 108 54 126 72 126 72 144 90 144 90 162 108 162 108 144 126 144 126 126 144 126 144 108 162 108 162 90 180 90 180 72 198 72 198 54 198 36 198 18 180 18"/>
    </g>
    <g>
      <rect class="heart-square primary" x="18" width="18" height="18"/>
      <rect class="heart-square secondary" y="18" width="18" height="18"/>
      <rect class="heart-square primary" y="36" width="18" height="18"/>
      <rect class="heart-square tertiary" y="54" width="18" height="18"/>
      <rect class="heart-square tertiary" x="18" y="72" width="18" height="18"/>
      <rect class="heart-square secondary" x="36" y="90" width="18" height="18"/>
      <rect class="heart-square tertiary" x="54" y="108" width="18" height="18"/>
      <rect class="heart-square tertiary" x="72" y="126" width="18" height="18"/>
      <rect class="heart-square tertiary" x="90" y="144" width="18" height="18"/>
      <rect class="heart-square tertiary" x="90" y="126" width="18" height="18"/>
      <rect class="heart-square tertiary" x="108" y="126" width="18" height="18"/>
      <rect class="heart-square secondary" x="72" y="108" width="18" height="18"/>
      <rect class="heart-square tertiary" x="90" y="108" width="18" height="18"/>
      <rect class="heart-square secondary" x="108" y="108" width="18" height="18"/>
      <rect class="heart-square tertiary" x="126" y="108" width="18" height="18"/>
      <rect class="heart-square tertiary" x="54" y="90" width="18" height="18"/>
      <rect class="heart-square tertiary" x="72" y="90" width="18" height="18"/>
      <rect class="heart-square tertiary" x="90" y="90" width="18" height="18"/>
      <rect class="heart-square tertiary" x="108" y="90" width="18" height="18"/>
      <rect class="heart-square secondary" x="126" y="90" width="18" height="18"/>
      <rect class="heart-square tertiary" x="144" y="90" width="18" height="18"/>
      <rect class="heart-square tertiary" x="36" y="72" width="18" height="18"/>
      <rect class="heart-square tertiary" x="54" y="72" width="18" height="18"/>
      <rect class="heart-square secondary" x="72" y="72" width="18" height="18"/>
      <rect class="heart-square tertiary" x="90" y="72" width="18" height="18"/>
      <rect class="heart-square primary" x="108" y="72" width="18" height="18"/>
      <rect class="heart-square tertiary" x="126" y="72" width="18" height="18"/>
      <rect class="heart-square tertiary" x="144" y="72" width="18" height="18"/>
      <rect class="heart-square tertiary" x="162" y="72" width="18" height="18"/>
      <rect class="heart-square primary" x="18" y="54" width="18" height="18"/>
      <rect class="heart-square tertiary" x="36" y="54" width="18" height="18"/>
      <rect class="heart-square primary" x="54" y="54" width="18" height="18"/>
      <rect class="heart-square tertiary" x="72" y="54" width="18" height="18"/>
      <rect class="heart-square primary" x="90" y="54" width="18" height="18"/>
      <rect class="heart-square tertiary" x="108" y="54" width="18" height="18"/>
      <rect class="heart-square primary" x="126" y="54" width="18" height="18"/>
      <rect class="heart-square tertiary" x="144" y="54" width="18" height="18"/>
      <rect class="heart-square secondary" x="162" y="54" width="18" height="18"/>
      <rect class="heart-square tertiary" x="180" y="54" width="18" height="18"/>
      <rect class="heart-square primary" x="18" y="36" width="18" height="18"/>
      <rect class="heart-square secondary" x="36" y="36" width="18" height="18"/>
      <rect class="heart-square tertiary" x="54" y="36" width="18" height="18"/>
      <rect class="heart-square primary" x="72" y="36" width="18" height="18"/>
      <rect class="heart-square secondary" x="90" y="36" width="18" height="18"/>
      <rect class="heart-square primary" x="108" y="36" width="18" height="18"/>
      <rect class="heart-square tertiary" x="126" y="36" width="18" height="18"/>
      <rect class="heart-square primary" x="144" y="36" width="18" height="18"/>
      <rect class="heart-square primary" x="162" y="36" width="18" height="18"/>
      <rect class="heart-square primary" x="180" y="36" width="18" height="18"/>
      <rect class="heart-square primary" x="18" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="36" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="54" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="72" y="18" width="18" height="18"/>
      <rect class="heart-square secondary" x="108" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="126" y="18" width="18" height="18"/>
      <rect class="heart-square secondary" x="144" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="162" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="180" y="18" width="18" height="18"/>
      <rect class="heart-square primary" x="36" width="18" height="18"/>
      <rect class="heart-square primary" x="54" width="18" height="18"/>
      <rect class="heart-square primary" x="126" width="18" height="18"/>
      <rect class="heart-square primary" x="144" width="18" height="18"/>
      <rect class="heart-square primary" x="162" width="18" height="18"/>
    </g>
  </svg>
</div>
              
            
!

CSS

              
                :root {
  --lovely-red: rgb(218,94,72); /* HEX#DA5E48 */
  --lovely-hot-pink: rgb(246,150,149); /* HEX#F69695 */
  --lovely-light-pink: rgb(251,193,161); /* HEX#FBC1A1 */
  --lovely-cream: rgb(242,243,238); /* HEX#F2F3EE */
}

html,
body {
  background-color: var(--lovely-cream);
  height: 100%;
  margin: 0;
}

.lovely-wrapper {
  margin: auto;
  display: flex;
  align-content: center;
  height: 100%;
}

.lovely-heart {
  width: 6rem;
  height: auto;
  margin: 0 auto;
}

.background-heart,
.heart-square {
  fill: var(--lovely-light-pink);
}

.animated.tertiary {
  animation-duration: 1s;
  animation-name: changeTertiary;
  animation-iteration-count: 1;
}

.animated.secondary {
  animation-duration: 1s;
  animation-name: changeSecondary;
  animation-iteration-count: 1;
}

@keyframes changeSecondary {
  0% {
    fill: var(--lovely-light-pink);
  }
  50% {
    fill: var(--lovely-hot-pink);
  }
  100% {
    fill: var(--lovely-light-pink);
  }
}
@keyframes changeTertiary {
  0% {
    fill: var(--lovely-light-pink);
  }
  50% {
    fill: var(--lovely-red);
  }
  100% {
    fill: var(--lovely-light-pink);
  }
}
              
            
!

JS

              
                const heartSquares = document.getElementsByClassName("heart-square");

for (let i = 0; i < heartSquares.length; i++) {
  const heartSquare = heartSquares[i];

  heartSquare.addEventListener("animationend", (_event) => {
    heartSquare.classList.remove("animated");
  });

  heartSquare.addEventListener("mouseover", (_event) => {
    heartSquare.classList.add("animated");
  });
}
              
            
!
999px

Console