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 id="christmas-decorations" class="christmas-decorations">
  <div class="tree">
    <div id="dropzone" class="tree-bottom"></div>
    <div id="dropzone-1"class="tree-middle"></div>
    <div id="dropzone-2" class="tree-top"></div>
  </div>
  <div id="decorations" class="decorations">
    <p class="text">Decorate the Christmas Tree:<p>
    <div id="ball1"></div>
    <div id="tree-star"></div>
    <div id="ball2"></div>
    <div id="ball3"></div>
    <div id="ball4"></div>
    <div id="ball5"></div>
    <div id="ball6"></div>
    <div id="bow"></div>
    <div id="bow2"></div>
    <div id="bow3"></div>
  </div>
  <div id="game-complete"><br/>Merry Christmas!!!</div>
</div>
              
            
!

CSS

              
                body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background-color: #5e6d5a;
}

.christmas-decorations {
  position: relative;
}

.christmas-decorations:before {
  content:"";
  position: absolute;
  border-radius:50%;
  background-color: rgba(0,0,0,0.5);
  width:200px;
  height:20px;
  top:180px;
  left:-80px;
}

.tree {
  position: relative;
  background-color: #57462a;
  width: 35px;
  height: 70px;
  top:120px;
}

.tree-bottom, .tree-middle {
  position: absolute;
  height:0;
  width:100px;
  border-right: 50px solid transparent;
  border-left: 50px solid transparent;
  border-bottom: 100px solid #64a85b;
}

.tree-bottom {
  top:-70px;
  left:-83px;
}

.tree-middle {
  top:-130px;
  left:-83px;
}

.tree-top {
  position: absolute;
  height:0;
  width:0;
  border-right: 70px solid transparent;
  border-left: 70px solid transparent;
  border-bottom: 120px solid #64a85b;
  top:-240px;
  left:-53px;
  z-index:1;
}

.tree-top:before {
  content:"";
  position: absolute;
  border-top: 10px solid rgba(0,0,0,0.5);
  border-right: 5px solid transparent;
  border-left: 105px solid transparent;
  top:120px;
  left:-50px;
  transform: skew(45deg);
}

.tree-top:after {
  content:"";
  position: absolute;
  border-top: 10px solid rgba(0,0,0,0.5);
  border-right: 5px solid transparent;
  border-left: 135px solid transparent;
  top:210px;
  left:-65px;
  transform: skew(45deg);
}

.decorations {
  position: absolute;
  width: 250px;
  height: 200px;
  background-color: white;
  left:-500px;
  top:-100px;
  box-shadow: 7px 7px rgba(0,0,0,0.5);
  z-index:3;
}

.text {
  text-align: center;
  font-weight: bold;
  font-family: tahoma;
  text-decoration: underline;
}

#ball1 {
  position: absolute;
  border-radius:50%;
  width:20px;
  height: 20px;
  background-color: #b65964;
  left:20px;
  cursor: pointer;
}

.tree-active {
  filter: brightness(110%);
}

#tree-star {
  position: absolute;
  display: block;
  width: 0px;
  height: 0px;
  border-right: 27px solid transparent;
  border-bottom: 20px solid #cec42f;
  border-left: 27px solid transparent;
  transform: rotate(-35deg);
  top:60px;
  left:50px;
  cursor: pointer;
    }

#tree-star:before {
      border-bottom: 20px solid #cec42f;
      border-left: 8px solid transparent;
      border-right: 8px solid transparent;
      position: absolute;
      height: 0;
      width: 0;
      top: -12.5px;
      left: -17.5px;
      display: block;
      content: '';
      transform: rotate(-35deg);
    }

#tree-star:after {
      position: absolute;
      display: block;
      top: 0.75px;
      left: -26.25px;
      width: 0px;
      height: 0px;
      border-right: 27px solid transparent;
      border-bottom: 20px solid #cec42f;
      border-left: 27px solid transparent;
      transform: rotate(-70deg);
      content:'';
}

#ball2 {
  position: absolute;
  border-radius:50%;
  width:22px;
  height: 22px;
  background-color: #7d45e6;
  left:120px;
  top:90px;
  cursor: pointer;
}

#ball3 {
  position: absolute;
  border-radius:50%;
  width:25px;
  height: 25px;
  background-color: #39bfd8;
  left:40px;
  top:120px;
  cursor: pointer;
}

#ball4 {
  position: absolute;
  border-radius:50%;
  width:23px;
  height: 23px;
  background-color: #cec431;
  left:80px;
  top:150px;
  cursor: pointer;
}

#ball5 {
  position: absolute;
  border-radius:50%;
  width:18px;
  height: 18px;
  background-color: #cec431;
  left:180px;
  top:150px;
  cursor: pointer;
}

#ball6 {
  position: absolute;
  border-radius:50%;
  width:25px;
  height: 25px;
  background-color: #b85863;
  left:180px;
  top:100px;
  cursor: pointer;
}

#bow {
  position: absolute;
  width: 1px;
  height: 0;
  border-bottom: 8px solid #7d45e6;
  border-top: 8px solid #7d45e6;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  transform: rotate(-90deg);
  left:170px;
  cursor: pointer;
}

#bow2 {
  position: absolute;
  width: 1px;
  height: 0;
  border-bottom: 7px solid #39bfd8;
  border-top: 7px solid #39bfd8;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  transform: rotate(-90deg);
  left:140px;
  top:160px;
  cursor: pointer;
}

#bow3 {
  position: absolute;
  width: 1px;
  height: 0;
  border-bottom: 7px solid #b85863;
  border-top: 7px solid #b85863;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  transform: rotate(-90deg);
  left:100px;
  top:130px;
  cursor: pointer;
}

#game-complete {
  display: none;
  position: absolute;
  font-size:60px;
  font-weight: bold;
  font-family: tahoma;
  color: #ae2012;
  text-shadow: 2px 2px #001219;
  top:-110px;
  left:-165px;
  z-index:4;
  text-align: center;
}
              
            
!

JS

              
                var score = 0;

$( function() {
	$("#ball1, #tree-star, #ball2, #ball3, #ball4, #ball5, #ball6, #bow, #bow2, #bow3 ").draggable({ revert: "invalid" });
  $("#dropzone, #dropzone-1, #dropzone-2").droppable({
			accept: "#ball1, #tree-star, #ball2, #ball3, #ball4, #ball5, #ball6, #bow, #bow2, #bow3 ",
      classes: {
        "ui-droppable-active": "tree-active",},
      drop: function() {
	  score++  
	finish();
  },
    });

function finish() {
	if(score === 12)
	{
		$('#game-complete').delay(300).fadeIn("fast");
       }
     }
   }); 

              
            
!
999px

Console