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.

            
              <link href="https://fonts.googleapis.com/css?family=Josefin+Slab" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<body>
  <h1>WE<i class="wi wi-hail"></i>THER APP</h1>
  <div class="main_box">
    
    <!--printing month,year,date and day for the user-->
    <div class="clock">
      <p id="month"></p>
      <p id="year"></p>
      <p id="date"></p>
      <p id="day"></p>
      <script>
        function myMonth() {
    		var month = new Array();
    		month[0] = "January";
    		month[1] = "February";
    		month[2] = "March";
    		month[3] = "April";
    		month[4] = "May";
    		month[5] = "June";
    		month[6] = "July";
   		 	month[7] = "August";
    		month[8] = "September";
    		month[9] = "October";
    		month[10] = "November";
    		month[11] = "December";
    		var d = new Date();
    		var n = month[d.getMonth()];
    		document.getElementById("month").innerHTML = n;
				}
        
        function myYear() {
    		var d = new Date();
    		var n = d.getFullYear();
    		document.getElementById("year").innerHTML = n;
				}
                
        function myDate() {
    		var d = new Date();
    		var n = d.getDate();
    		document.getElementById("date").innerHTML = n;
				}
        
        function myDay() {
    		var d = new Date();
    		var weekday = new Array(7);
   		 	weekday[0] = "Sunday";
    		weekday[1] = "Monday";
    		weekday[2] = "Tuesday";
    		weekday[3] = "Wednesday";
    		weekday[4] = "Thursday";
    		weekday[5] = "Friday";
    		weekday[6] = "Saturday";
    		var n = weekday[d.getDay()];
    		document.getElementById("day").innerHTML = n;
				}
        
        myMonth();
        myYear();
        myDate();
        myDay();
        
      </script>
    </div>
    <!--END--printing month,year,date and day for the user--END-->
    <!-- printing current location of user-->
    <div class="city"></div>
    <div class="temp"></div>
     
    <div class="btn-group button-group" role="group">
					<button id="cel" class="btn btn-default btn-lg"><b>°C</b></button>  <!-- Celsius Button -->
					<button id="fah" class="btn btn-default btn-lg"><b>°F</b></button>  <!-- Fahrenheit Button -->
    </div>
  
 <!--Animated weather-icons-->
    <div class="all_icon">
<div class="icon sun-shower hide">
  <div class="cloud"></div>
  <div class="sun">
    <div class="rays"></div>
  </div>
  <div class="rain"></div>
</div>

<div class="icon thunder-storm hide thunderstom">
  <div class="cloud"></div>
  <div class="lightning">
    <div class="bolt"></div>
    <div class="bolt"></div>
  </div>
</div>

<div class="icon cloudy hide clouds">
  <div class="cloud"></div>
  <div class="cloud"></div>
</div>

<div class="icon flurries hide snow">
  <div class="cloud"></div>
  <div class="snow">
    <div class="flake"></div>
    <div class="flake"></div>
  </div>
</div>

<div class="icon sunny hide clear">
  <div class="sun">
    <div class="rays"></div>
  </div>
</div>

<div class="icon rainy hide rain">
  <div class="cloud"></div>
  <div class="rain"></div>
</div>
    
    </div>
 <!--End-aNIMATED WEATHER ICONS--END-->
    
   
    <div class="cat"></div>
    <div class="desc"></div>
    <div class="hum"></div>
    <div class="wind"></div>
  </div>
</body>
            
          
!
            
              body{
  color:#fff;
  height:100%;
  weidth:100%;
  background:#161616;;
 }
h1{
  font-size:2.5em;
  font-weight:bold;
  text-align:center;
  font-family:'Josefin Slab';
  color:#909090;;
}
.main_box{
  margin:auto;
  height:40em;
  width:35em;
  /*box-shadow:0 0 10px #230913;*/
  background:#161616;
  border-radius:2%;
  padding:15px 10px 5px 10px;
  text-align:center;
  font-family:'Josefin Slab';
 }
.clock{
  color:#fff;
  font-family:'Josefin Slab';
  padding-top:10px;
  height:6.8em;
  width:7.6em;
  margin:auto;
  background-color:#161616;
  border-radius:5%;
  border:2px solid #fff;
  box-shadow:inset 0 1px rgba(255,255,255,.1), /* Top shine */
    0 6px 5px -5px rgba(38,38,38,.5), /* Shadow1 */
    0 7px 0  -2px rgba(56,56,56,1), /* Flip1 */
     0 11px 5px -5px rgba(0,0,0,.5)/*Shadow2 */
   
  }
#month{
  display:inline;
  font-weight:bold;
  padding-left:-3px;
  font-style:Oblique;
  font-size:1.1em;
 }
#year{
  display:inline;
  font-weight:bold;
  font-style:Oblique;
  font-size:1.1em;
 }
#date{
  font-weight:bold;
  font-size:3em;
  margin-top:4%;
  text-shadow: 2px 2px #424242;
  }
#day{
  margin-top:-40%;
  font-size:1.3em;
  padding-bottom:7px;
}
.city{
  font-family:'Josefin Slab';
  text-align:center;
  padding:1.5em 0 1.2em 0 ;
  font-size:2em;
  }
.temp{
  font-family:'Josefin Slab';  
  font-size:1.5em;
  margin-top:-5%;
}


/*ANIMATED WEATHED ICONS*/
html { box-sizing: border-box; }
html *,
html *:before,
html *:after { box-sizing: inherit; }

.all_icon{
  background-color: currentColor;
  color: #161616;/*#71042F;*/
  margin:auto;
  margin-top:4em;
}
div.hide {
  display: none;
}
.icon {
  position: relative;
  display: inline-block;
  width: 12em;
  height: 6em;
  font-size: 2em; /* control icon size here */
}

.cloud {
  position: absolute;
  z-index: 1;
  top: 30%;
  left: 50%;
  width: 3.6875em;
  height: 3.6875em;
  margin: -1.84375em;
  background: currentColor;
  border-radius: 50%;
  box-shadow:
    -2.1875em 0.6875em 0 -0.6875em,
    2.0625em 0.9375em 0 -0.9375em,
    0 0 0 0.375em #fff,
    -2.1875em 0.6875em 0 -0.3125em #fff,
    2.0625em 0.9375em 0 -0.5625em #fff;
}
.cloud:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -0.5em;
  display: block;
  width: 4.5625em;
  height: 1em;
  background: currentColor;
  box-shadow: 0 0.4375em 0 -0.0625em #fff;
}
.cloud:nth-child(2) {
  z-index: 0;
  background: #fff;
  box-shadow:
    -2.1875em 0.6875em 0 -0.6875em #fff,
    2.0625em 0.9375em 0 -0.9375em #fff,
    0 0 0 0.375em #fff,
    -2.1875em 0.6875em 0 -0.3125em #fff,
    2.0625em 0.9375em 0 -0.5625em #fff;
  opacity: 0.3;
  transform: scale(0.5) translate(6em, -3em);
  animation: cloud 4s linear infinite;
}
.cloud:nth-child(2):after { background: #fff; }

.sun {
  position: absolute;
  top: 30%;
  left: 50%;
  width: 2.5em;
  height: 2.5em;
  margin: -1.25em;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 0.375em #fff;
  animation: spin 12s infinite linear;
}
.rays {
  position: absolute;
  top: -2em;
  left: 50%;
  display: block;
  width: 0.375em;
  height: 1.125em;
  margin-left: -0.1875em;
  background: #fff;
  border-radius: 0.25em;
  box-shadow: 0 5.375em #fff;
}
.rays:before,
.rays:after {
  content: '';
  position: absolute;
  top: 0em;
  left: 0em;
  display: block;
  width: 0.375em;
  height: 1.125em;
  transform: rotate(60deg);
  transform-origin: 50% 3.25em;
  background: #fff;
  border-radius: 0.25em;
  box-shadow: 0 5.375em #fff;
}
.rays:before {
  transform: rotate(120deg);
}
.cloud + .sun {
  margin: -2em 1em;
}

.rain,
.lightning,
.snow {
  position: absolute;
  z-index: 2;
  top: 38%;
  left: 50%;
  width: 3.75em;
  height: 3.75em;
  margin: 0.375em 0 0 -2em;
  background: currentColor;
}

.rain:after {
  content: '';
  position: absolute;
  z-index: 2;
  top: 30%;
  left: 50%;
  width: 1.125em;
  height: 1.125em;
  margin: -1em 0 0 -0.25em;
  background: #0cf;
  border-radius: 100% 0 60% 50% / 60% 0 100% 50%;
  box-shadow:
    0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
    -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
    -1.375em -0.125em 0 rgba(255,255,255,0.2);
  transform: rotate(-28deg);
  animation: rain 3s linear infinite;
}

.bolt {
  position: absolute;
  top: 30%;
  left: 50%;
  margin: -0.25em 0 0 -0.125em;
  color: #fff;
  opacity: 0.3;
  animation: lightning 2s linear infinite;
}
.bolt:nth-child(2) {
  width: 0.5em;
  height: 0.25em;
  margin: -1.75em 0 0 -1.875em;
  transform: translate(2.5em, 2.25em);
  opacity: 0.2;
  animation: lightning 1.5s linear infinite;
}
.bolt:before,
.bolt:after {
  content: '';
  position: absolute;
  z-index: 2;
  top: 30%;
  left: 50%;
  margin: -1.625em 0 0 -1.0125em;
  border-top: 1.25em solid transparent;
  border-right: 0.75em solid;
  border-bottom: 0.75em solid;
  border-left: 0.5em solid transparent;
  transform: skewX(-10deg);
}
.bolt:after {
  margin: -0.25em 0 0 -0.25em;
  border-top: 0.75em solid;
  border-right: 0.5em solid transparent;
  border-bottom: 1.25em solid transparent;
  border-left: 0.75em solid;
  transform: skewX(-10deg);
}
.bolt:nth-child(2):before {
  margin: -0.75em 0 0 -0.5em;
  border-top: 0.625em solid transparent;
  border-right: 0.375em solid;
  border-bottom: 0.375em solid;
  border-left: 0.25em solid transparent;
}
.bolt:nth-child(2):after {
  margin: -0.125em 0 0 -0.125em;
  border-top: 0.375em solid;
  border-right: 0.25em solid transparent;
  border-bottom: 0.625em solid transparent;
  border-left: 0.375em solid;
}

.flake:before,
.flake:after {
  content: '\2744';
  position: absolute;
  top: 30%;
  left: 50%;
  margin: -1.025em 0 0 -1.0125em;
  color: #fff;
  list-height: 1em;
  opacity: 0.2;
  animation: spin 8s linear infinite reverse;
}
.flake:after {
  margin: 0.125em 0 0 -1em;
  font-size: 1.5em;
  opacity: 0.4;
  animation: spin 14s linear infinite;
}
.flake:nth-child(2):before {
  margin: -0.5em 0 0 0.25em;
  font-size: 1.25em;
  opacity: 0.2;
  animation: spin 10s linear infinite;
}
.flake:nth-child(2):after {
  margin: 0.375em 0 0 0.125em;
  font-size: 2em;
  opacity: 0.4;
  animation: spin 16s linear infinite reverse;
}


/* Animations */ 

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@keyframes cloud {
  0% { opacity: 0; }
  50% { opacity: 0.3; }
  100% {
    opacity: 0;
    transform: scale(0.5) translate(-200%, -3em);
  }
}

@keyframes rain {
  0% {
    background: #0cf;
    box-shadow:
      0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
      -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
      -1.375em -0.125em 0 #0cf;
  }
  25% {
    box-shadow:
      0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
      -0.875em 1.125em 0 -0.125em #0cf,
      -1.375em -0.125em 0 rgba(255,255,255,0.2);
  }
  50% {
    background: rgba(255,255,255,0.3);
    box-shadow:
      0.625em 0.875em 0 -0.125em #0cf,
      -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
      -1.375em -0.125em 0 rgba(255,255,255,0.2);
  }
  100% {
    box-shadow:
      0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
      -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
      -1.375em -0.125em 0 #0cf;
  }
}

@keyframes lightning {
  45% {
    color: #fff;
    background: #fff;
    opacity: 0.2;
  }
  50% {
    color: #0cf;
    background: #0cf;
    opacity: 1;
  }
  55% {
    color: #fff;
    background: #fff;
    opacity: 0.2;
  }
}

/*end-ANIMATED WEATHER ICONS-end*/

.cat{
  font-family:'Josefin Slab';
  font-size:1.5em;
}
.desc{
  font-family:'Josefin Slab';
  font-size:1.5em;
}
.hum{
  font-family:'Josefin Slab';
  font-size:1.5em;
}
.wind{
  font-family:'Josefin Slab';
  font-size:1.5em;
  padding-bottom:10px;
}
            
          
!
            
              $(document).ready(function() {
	$(".temp").html("<b>Please Wait...</b>");
	if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) { 			$.getJSON("https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude + "&appid=8c2f2aa77f79ee0b57f1849635b15d73", function(json) {
				$(".city").html("<b>" + json.name + " (" + json.sys.country + ") </b>");  //City name, country name
      	var ctemp = json.main.temp - 273;  // converting kelvin to celsius
				$(".temp").html("<b>" + Math.round(ctemp) + " °C" + "</b>");  //temperature
				$(".cat").html("<b>" + json.weather[0].main + "</b>");  //weather category
				$(".desc").html(json.weather[0].description + "<br><b></b>");  //weather description
				$(".hum").html("Humidity  <b>" + json.main.humidity + "%</b>");  //humidity
				$(".wind").html("Wind Speed  <b>" + json.wind.speed + " m/s</b>");  //wind speed
				$("#cel").on("click", function () {
					$(".temp").html("<b>" + Math.round(ctemp) + " °C" + "</b>");
				});
				$("#fah").on("click", function () {
					var ftemp = ctemp * (9 / 5) + 32;
					$(".temp").html("<b>" + Math.round(ftemp) + " °F" + "</b>");
				});
      
			//function to hide-display weather icons
      var weather_description=json.weather[0].description;
      function IconGen(city) {
    var city = city.toLowerCase()
    switch (city) {
      case 'dizzle':
        addIcon(city)
        break;
      case 'clouds':
        addIcon(city)
        break;
      case 'rain':
        addIcon(city)
        break;
      case 'snow':
        addIcon(city)
        break;
      case 'clear':
        addIcon(city)
        break;
      case 'thunderstom':
        addIcon(city)
        break;
      default:
    $('div.clouds').removeClass('hide');
    }
  }

  function addIcon(city) {
    $('div.' + city).removeClass('hide');
  }
 //**END**function to hide-display weather icons
  IconGen(weather_description);
			});
		});
	}
});
            
          
!
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