css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div id="wrap">
  <div class='heart gold'></div>
</div>
<div class='heart silver'></div>
<div class='heart bronze1'></div>
<div class='heart bronze2'></div>
<div class='heart bronze3'></div>
<div class='heart black'></div>
            
          
!
            
              .heart.gold:after {
  background: linear-gradient(
    -72deg,
    #ffde45,
    #ffffff 16%,
    #ffde45 21%,
    #ffffff 24%,
    #452100 27%,
    #ffde45 36%,
    #ffffff 45%,
    #ffffff 60%,
    #ffde45 72%,
    #ffffff 80%,
    #ffde45 84%,
    #452100
  );
}

.heart.black:after {
  background: linear-gradient(
    to bottom,
    #4c4c4c 0%,
    #595959 12%,
    #666666 25%,
    #474747 39%,
    #2c2c2c 50%,
    #000000 51%,
    #111111 60%,
    #2b2b2b 76%,
    #1c1c1c 91%,
    #131313 100%
  );
}
.heart.bronze1:after {
  background: linear-gradient(
    -72deg,
    #ca7345,
    #ffdeca 16%,
    #ca7345 21%,
    #ffdeca 24%,
    #a14521 27%,
    #ca7345 36%,
    #ffdeca 45%,
    #ffdeca 60%,
    #ca7345 72%,
    #ffdeca 80%,
    #ca7345 84%,
    #732100
  );
}
.heart.silver:after {
  background: linear-gradient(
    -72deg,
    #dedede,
    #ffffff 16%,
    #dedede 21%,
    #ffffff 24%,
    #caa1de 27%,
    #dea1ca 30%,
    #dedede 38%,
    #ffffff 45%,
    #ffffff 60%,
    #dedede 72%,
    #ffffff 80%,
    #dedede 84%,
    #caa1de 93%,
    #dea1ca
  );
}
.heart.bronze2:after {
  background: linear-gradient(
    -72deg,
    #ca7345,
    #ffdeca 16%,
    #ca7345 21%,
    #ffdeca 24%,
    #a14521 27%,
    #ca7345 36%,
    #ffdeca 45%,
    #ffdeca 60%,
    #ca7345 72%,
    #ffdeca 80%,
    #ca7345 84%,
    #732100
  );
}

.heart.bronze3:after {
  background: linear-gradient(
    -72deg,
    #ca7345,
    #ffdeca 16%,
    #ca7345 21%,
    #ffdeca 24%,
    #a14521 27%,
    #ca7345 36%,
    #ffdeca 45%,
    #ffdeca 60%,
    #ca7345 72%,
    #ffdeca 80%,
    #ca7345 84%,
    #732100
  );
}

.heart {
  position: relative;
  width: 100px;
  height: 90px;
  float: center;
  bottom: 0px;
  left: 100px;

  animation: heartbeat 1s infinite;
}
.heart:before,
.heart:after {
  transform: scale(2);
  position: absolute;
  content: "";
  left: 50px;
  bottom: 10;
  width: 50px;
  height: 80px;
  background: #fc2e5a;
  -moz-border-radius: 50px 50px 0 0;
  border-radius: 50px 50px 0 0;
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  transform: rotate(-45deg);
  -webkit-transform-origin: 0 100%;
  -moz-transform-origin: 0 100%;
  -ms-transform-origin: 0 100%;
  -o-transform-origin: 0 100%;
  transform-origin: 0 100%;
}
.heart:after {
  left: 0;
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  transform: rotate(45deg);
  -webkit-transform-origin: 100% 100%;
  -moz-transform-origin: 100% 100%;
  -ms-transform-origin: 100% 100%;
  -o-transform-origin: 100% 100%;
  transform-origin: 100% 100%;
}
@keyframes heartbeat {
  0% {
    transform: scale(0.75);
  }
  20% {
    transform: scale(1);
  }
  40% {
    transform: scale(0.75);
  }
  60% {
    transform: scale(1);
  }
  80% {
    transform: scale(0.75);
  }
  100% {
    transform: scale(0.75);
  }
}

            
          
!
            
              $(function() {

  $('.heart').each(function() {
    animateDiv(this);
  });

  var beatingSpeed = 4;
  var speed = 'heartbeat ' + beatingSpeed + 's' + ' infinite';

  $('.heart').css('animation', speed);
  function makeNewPosition() {
    // Get viewport dimensions (remove the dimension of the div)
    var h = $(window).height() - 50;
    var w = $(window).width() - 50;

    var nh = Math.floor(Math.random() * h);
    var nw = Math.floor(Math.random() * w);

    return [nh, nw];
  }

  function animateDiv(myclass) {

    var newq = makeNewPosition();

    if ($(myclass).hasClass('gold')) var movingSpeed = 500;
    else movingSpeed = 5000;

    $(myclass).animate({ top: newq[0], left: newq[1] }, movingSpeed, 'linear', function() {
      animateDiv(myclass);
    });
  }

  $('.heart').on('click', function() {
    var theClass = this.className; // 'this' is the element clicked
    alert(theClass);
    if (theClass == 'heart gold') {
      $(theClass).animate({ top: newq[0], left: newq[1] }, 10, 'linear', function() {
        animateDiv(theClass);
      });
    }

    var val = 0.5;
    $('#wrap').css({
      '-webkit-transform': 'scale(' + val + ')',
      '-moz-transform': 'scale(' + val + ')',
      '-ms-transform': 'scale(' + val + ')',
      '-o-transform': 'scale(' + val + ')',
      transform: 'scale(' + val + ')'
    });
  });

  $('div.heart').click(function() {
    $(this).remove();
  });
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console