123

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.

            
              /* Pure CSS style */
		@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:400');

		*, body, div, ul, li {
		  margin: 0;
		  padding: 0;
		  box-sizing: border-box;
		  overflow: hidden;
		 
		}
		
		body {
		  width: 100vw;
		  height: 100vh;
		  background: #bedbe9;
		}
		
		#xmas_tree {
		  width: 100%;
		  height: 100%;
		  display: flex;
		  justify-content: center;
		  align-items: center;
		  background: none;
		  border:1.1rem solid #EBF4F8;
		}
		
		#xmas_tree ul:nth-child(2){
			position: absolute;
			margin: 0 auto;
			margin-top: -2rem;
			z-index: 2;
		  }
		
		@media (min-min-width:769px){
		  #xmas_tree ul:nth-child(2){
			margin-top: -3.05rem;
		  }
		}
		
		ul li ul{
		  display: flex;
		  justify-content: center;
		  align-items: center;
		}
		
		#xmas_tree ul li ul li {
		  height: 0; 
		  width: 0;
		}
		
		#xmas_tree ul:nth-child(1) li ul li {
		  margin:.5rem;
		  border-left: 1rem solid transparent;
		  border-bottom: 2rem solid #CCE2ED;
		  border-right: 1rem solid transparent;
		  filter: drop-shadow(-.8px 3px 2px #52A1C4);
		}

		@media (min-min-width:769px) {
		  #xmas_tree ul:nth-child(1) li ul li {
		    border-left: 2rem solid transparent;
		    border-bottom: 4rem solid #3B4B6F;
		    border-right: 2rem solid transparent;
		  }
		}
		
		#xmas_tree ul:nth-child(2) li ul li {
		  margin: 1rem;
		  border: .5rem solid #DCEBF2;
		  border-radius: 50%;
		  filter: drop-shadow(-.5px 2px 1.5px #5DABCE);
      -webkit-transition: -webkit-transform .15s;
      transition: transform .15s;
		}
		
		@media (min-min-width:769px){
		  #xmas_tree ul:nth-child(2) li ul li {
		    margin: 1.7rem;
		    border: .8rem solid #DCEBF2;
		  }
		}

		ul:nth-child(2) li ul:hover li {
		  transform: scale(1.15);
		}

		#timer {
		  position: absolute;
		  margin: 0 auto;
		  bottom: 5rem;
		  display: block;
		  font-family: 'Source Code Pro', monospace; /* Monospace type font to avoid width change of text line for second, etc. */
		  font-size: 3rem;
		  color: #e8eff6;
		  text-shadow: -1px 1px 1px rgba(77,147,181,.6),
						1px -1px 0 rgba(221,234,242,.9);
		  z-index: 3;
		}
		
		@media (min-width:600px) {
		  #timer {
		    margin-top: 0;
			bottom: 4.5rem;
		    font-size: 2rem;
		  }
		}
            
          
!
            
              // Count Down Timer for the New Year 2020 in France, GMT +01

// JS Manipulations with DOM :
		window.onload = function(){
		
		  // XMAS TREE
		  var div = document.body.appendChild(document.createElement('div'));
		  div.id = 'xmas_tree';
		  
		  // Create two layouts of lists for (Xmas tree & light) :
		  var list = document.createElement('ul'),li;
		  
		  // Create six lines for Xmas Tree :
		  for (var i = 0; i <= 5; i++){
		    var li = list.appendChild(document.createElement('li'));
			var ul = li.appendChild(document.createElement('ul'));
			list.appendChild(li);
		  }
		   
		  var ul_1 = div.appendChild(list);
		  var ul_2 = div.appendChild(ul_1.cloneNode(true));
		  
		  // Create items of Xmas Tree with progressive increment :
		  var ulArr = document.querySelectorAll('div ul li ul');
		  function xmasTree() {
			for(var i = 0; i <= 11; i++) {
			  if(ulArr[i]) {
			    if(i <= 5) {
			      for (var j = 0; j <= i; j++) {
			        ulArr[i].appendChild(li.cloneNode(false));
				  }
			    }
				else {
				  for (var k = 0; k > 5 - i; k--) {
			        ulArr[i].appendChild(li.cloneNode(false));
				  }
				}
		      }
		    }
		  }
		  xmasTree();
		  		  
		  var timer = div.appendChild(div.cloneNode(false));
		  timer.id = 'timer';
		  
		
		// Count Down Timer

			// Set the date we are counting down to the New Year in France :
			var countDownDate = new Date("Jan 1, 2020 00:00:00 GMT+01:00").getTime();

			// Update the count down every 1 second :
			var x = setInterval(function() {

			  // Get todays date and time :
			  var now = new Date().getTime();

			  // Find the time left between now an the New Year 2018 in France:
			  var left = countDownDate - now;

			  // Time calculations for days, hours, minutes and seconds :
			  var days = Math.floor(left / (1000 * 60 * 60 * 24));
			  var hours = Math.floor((left % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
			  var minutes = Math.floor((left % (1000 * 60 * 60)) / (1000 * 60));
			  var seconds = Math.floor((left % (1000 * 60)) / 1000);
			  
			  if(days < 10){
				days = '0' + days;
			  }
			  if (hours < 10){
				hours = '0' + hours;
			  }
			  if (minutes < 10){
				minutes = '0' + minutes;
			  }
			  if (seconds < 10){
				seconds = '0' + seconds;
			  }

			  // Display the result in French style with id="timer" element :
			  document.getElementById("timer").innerHTML = days + "j " + hours + "h" + minutes + " " + seconds + "s ";

			  // If the count down is finished, write felicitations :
			  if (left < 0) {
				clearInterval(x);
				document.getElementById("timer").innerHTML = "BONNE ANNÉE !";
			  }
			}, 1000);
		}		
            
          
!
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.

Console