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

              
                <div class='heart' style="display:none">
  <svg viewBox="0 0 171 360" class="heart-half">
  <path d="M 171 360 C 171.371 359.264 17.176 227.534 3.901 145.841 C -9.374 64.148 25.345 21.26 70.276 5.943 C 115.207 -9.374 169.497 1.574 171 98.868 L 171 360 Z"/>
</svg>
  <svg viewBox="0 0 171 360" class="heart-half right">
  <path d="M 170.333 1.009 C 170.333 1.009 16.138 132.739 2.863 214.432 C -10.412 296.125 24.307 339.013 69.238 354.331 C 114.169 369.647 168.459 358.699 171 261.405 L 170.333 1.009 Z" transform="matrix(-1, 0, 0, -1, 170.333013, 361.008992)"/>
</svg>
</div>

<div class='container'>
  <div class='wrapper'>
<button class="sg-button-secondary sg-button-secondary--small sg-button-secondary--active-inverse js-button">
            <div class="sg-label sg-label--secondary sg-label--unstyled">
                <div class="sg-label__icon">
                    <svg class="sg-icon sg-icon--x16 sg-icon--adaptive">
                        <use xlink:href="#icon-heart"></use>
                    </svg>
                </div>
                <div class="sg-label__text">Thank you</div>
            </div>
        </button>
  </div>
</div>
              
            
!

CSS

              
                .container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wrapper {
  position: relative;
}

.heart {
  animation: die 1.6s ease-in-out;
  animation-fill-mode: forwards;
  transform: scale(0);
  display: inline-flex;
  height: 50px;
  position: absolute;
  left: 20px;
  top: 10px;
  z-index: -1;
}

.heart-half {
  margin: -1px;
  padding: 0;
  height: 100%;
  fill: #ff796b;
  stroke: none;
  transform-origin: 100% 50%;
  transform: rotateY(0deg);
  animation: flap 0.3s infinite ease-in-out;
}

.heart-half.right {
  transform-origin: 0 50%;
  animation: flap2 0.3s infinite ease-in-out;
}

@keyframes flap {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(60deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

@keyframes flap2 {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(60deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

@keyframes die {
  from {
    offset-distance: 0;
    transform: scale(0);
  }
  33% {
    transform: scale(1);
    z-index: 1;
    offset-distance: 75%;
  }
  to {
    offset-distance: 100%;
    transform: scale(0);
    z-index: 1;
  }
}
              
            
!

JS

              
                const proto = document.querySelector('.heart');
const wrapper = document.querySelector('.wrapper');

function rand(min,max) {
  return Math.random() * (max-min) + min;
}

function go() {
  for (var i=0; i<10; i++) {
    const heart = proto.cloneNode(true);
    heart.style.display = 'inline-flex';

    heart.style.animationDelay = `${rand(0,0.3)}s`;
     heart.style.offsetPath = `path('M0,0 c 0,-200 ${rand(-200, 200)},${rand(-50, 50)} ${rand(-200, 200)},${rand(-50, 50)}')`;

    wrapper.append(heart);
  }
}

const button = document.querySelector('.js-button');

button.addEventListener('click', () => {
  go();
  button.blur();
});

              
            
!
999px

Console