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

              
                #app 
  .explosion
    img(src="")
  .extinguisher
  .question 
    h1 ๐Ÿ˜”<br> Do you want to unsubscribe? 
    button.yes-button Yes
    button.no-button Cancel
  .animation(style="display:none")
    button.unsubscribe-button Unsubscribe
    .box#fireBox
      img(src="https://i.imgur.com/6vkGRDR.gif")
    p.animated.pulse.infinite โš ๏ธ<br> Please take fire extinguisher and stop the fire to be able to unsubscribe.
  .result(style="display:none;") 
    h1 ๐ŸŽ‰ Yay! <br> You have succesfully unsubscribed.
    button.reset-button Reset
  
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Varela+Round&display=swap');

$red = #e25822
$grey = #ddd
$fontColor = #444
$radius = 5px

*
  font-family 'Varela Round', sans-serif
  font-size 16px
  color $fontColor
  
h1 
  font-size 25px
  margin 0 0 20px

button 
 border 1px solid $grey
 border-radius $radius
 font-size 16px
 padding 6px 10px
 &.no-button 
   color $red
   border-color $red
  

  
#app 
  position relative
  width 350px
  margin 60px auto
  text-align center
  border 1px solid $grey
  border-radius $radius
  padding 30px 20px
  &.active 
    border-color $red
  
.box
  width:100px
  height 100px
  margin 0 auto
  img 
    max-width 100%
    display block
 

.question > button
  margin-right 10px
  
.animation 
  cursor none    
  
.extinguisher
  cursor pointer
  display none
  width 100px
  height 50px
  position absolute 
  font-size 30px
  left -80px 
  top -10px
  background-image url("https://i.imgur.com/jGZFxMt.gif")
  background-repeat no-repeat
  background-size 100px auto
  background-position 70px 0px
  &.active 
    background-position 0 0
    
.explosion
  position absolute
  top 0 
  left 0
  z-index 2
  width 100%
  height 100%
  display none
  img 
    width 100%
    height 100%
              
            
!

JS

              
                var buttonOpacity = 1;
var buttonTimer;
var fireOpacity = 1;
var fireTimer;
var explosionGif = "https://mburakerman.com/firemember/img/explosion.gif";

function bindAnimation() {
  $(".explosion")
    .show()
    .end()
    .find(".explosion img")
    .attr("src", explosionGif)
    .delay(1000)
    .queue(function() {
      $(".explosion")
        .hide()
        .end()
        .find(".explosion img")
        .attr("src", "");
      $(".extinguisher").show();

      buttonTimer = setInterval(function() {
        buttonOpacity -= 0.1;
        $(".unsubscribe-button").css("opacity", buttonOpacity);
        if (Number(buttonOpacity) < 0.9) {
          disableUnsubscribe();
        } else {
          enableUnsubscribe();
        }

        if (String(buttonOpacity).includes("-")) {
          clearInterval(buttonTimer);
          buttonOpacity = 1;
          resetApp();
        }
      }, 1000);

      bindDragAndDrop();
    });
}

function bindDragAndDrop() {
  $(".extinguisher").draggable({
    start: function() {
      $(".extinguisher").addClass("active");
    },
    stop: function() {
      $(".extinguisher").removeClass("active");
    }
  });

  $("#app").droppable({
    accept: ".extinguisher",
    hoverClass: "active",
    activate: function() {},
    drop: function(event, ui) {
      clearInterval(fireTimer);
    },
    out: function() {
      clearInterval(fireTimer);
    },
    over: function() {
      fireTimer = setInterval(function() {
        fireOpacity -= 0.2;
        $("#fireBox").css("opacity", fireOpacity);

        if (String(fireOpacity).includes("-")) {
          clearInterval(fireTimer);
          clearInterval(buttonTimer);
          fireOpacity = 1;
          buttonOpacity = 1;
          $(".unsubscribe-button").css("opacity", buttonOpacity);
          $(".animation")
            .find("p")
            .removeAttr("class");
          enableUnsubscribe();
        }
      }, 1000);
    }
  });
}

function enableUnsubscribe() {
  $(".unsubscribe-button").css({
    pointerEvents: "auto",
    cursor: "pointer"
  });
}

function disableUnsubscribe() {
  $(".unsubscribe-button").css({
    pointerEvents: "none",
    cursor: "not-allowed"
  });
}

function resetApp() {
  history.go(0);
}

function bindApp() {
  $(".yes-button").on("click", function() {
    $(".question").fadeOut(300, function() {
      $(".animation").fadeIn(300);
      bindAnimation();
    });
  });

  $(".unsubscribe-button").on("click", function() {
    $(".animation, .extinguisher").fadeOut(300, function() {
      $(".result").fadeIn(300);
    });
  });
  $(".reset-button").on("click", resetApp);
}
$(function() {
  bindApp();
});

              
            
!
999px

Console