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.

            
              <head>
  <!-- import google fonts --> 
  <link href="https://fonts.googleapis.com/css?family=ABeeZee" rel="stylesheet">
  <!-- importing font awesome icons --> 
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <!-- import jQuery --> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
  <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js"></script>
</head>

<div class="cloud-intro"> 
<!-- single page application --> 
<body> 
<div class="container-fluid">
  <h1><strong> Local Weather App </strong></h1> 
  <button id="getWeather" class="btn btn-primary" style="margin-bottom:40px; margin-top:40px;"><h2> Check Weather </h2></button> 
  <div class="weather"> 
    <div class="locationContainer hide">
      <h2><span id="location"></span></h2>
    </div>
    <h2><span id="description"></span>
    <!-- icon appear next to weather description (inline element) -->   
    <span>
      <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 thunderstorm">
        <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>
    </span></h2>
    <h2><span id="temp"></span><span id="tempUnit" ></span></h2>
  </div>
  <br>  
  <input type="image" src="https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/Celsius-Red.png?raw=true" alt="celsius-RED" id="toCelsius">
  <h2 class="textBetweenImg"> OR </h2>
  <input type="image" src="https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/Fahrenheit-Red.png?raw=true" alt="fahrenheit-RED" id="toFahrenheit"> 
  <!-- displays error message if unable to retrieve geolocation data --> 
  <h4><span id="error"></span><h4>
  <br><br><br><br><br><br><br>
  <h4> Location services must be turned on. Go to Settings -> Privacy -> Location Services </h4> 
  <h4> If it still doesn't work, check out this <a href="https://user-images.githubusercontent.com/30268174/28568721-651b3360-7169-11e7-80df-a419fd5c7f53.gif" target="_blank">DEMO</a></h4>
  <br>
  <div class="credits">
    <h3>Icon animation credits to <a href="https://codepen.io/joshbader/full/EjXgqr/" target="_blank">joshbader</a></h3>
  </div>
</div>
<!-- closing tag for cloud animations --> 
</div>

<!-- The footer -->
<footer>
  <p>Copyright © Chris Jim 2017. All Rights Reserved</p>
  <p>
    <a href="mailto:chrisjim316@gmail.com"><i class="fa fa-envelope"></i></a>
    <a href="https://www.linkedin.com/in/chris-jim-77b090128/" target="_blank"><i class="fa fa-linkedin"></i></a>
    <a href="https://github.com/chrisjim316" target="_blank"><i class="fa fa-github"></i></a>
    <a href="https://www.quora.com/profile/Chris-Jim-1" target="_blank"><i class="fa fa-quora"></i></a>
    <a href="https://www.freecodecamp.com/chrisjim316" target="_blank"><i class="fa fa-free-code-camp"></i></a>
  </p>
</footer>
    
</body>
  


            
          
!
            
              body {
  background: url("https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/background.jpg?raw=true");
  color: white; 
  font-family: 'ABeeZee', sans-serif;
  text-align: center; 
  padding-top: 20px;
  background-size: cover; 
  height: 1400px;
}

.locationContainer {
  padding: 5px 5px 5px 5px;
  height: 100px;
  display: inline-block;
  background-color: rgba(255, 255, 255, 0.2);
  resize: none;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-border: 1px solid white;
  -webkit-border: 1px solid white;
  border-radius: 4px;
  -moz-border-radius: 4px;
  -webkit-border-radius: 4px;
  box-shadow: 0px 5px 12px 1px rgba(0, 0, 0, 0.6), 0 4px 3px rgba(0, 0, 0, 0.5), inset 0px 0px 6px 3px rgba(0, 0, 0, 0.5), 0 -0.5px 3px rgba(0, 0, 0, 0.1);
  -moz-box-shadow: 0px 9px 12px 1px rgba(0, 0, 0, 0.4), 0 10px 3px rgba(0, 0, 0, 0.1), inset 0px 0px 6px 3px rgba(0, 0, 0, 0.1), 0 -0.5px 3px rgba(0, 0, 0, 0.1);
  -webkit-box-shadow: 0px 9px 12px 1px rgba(0, 0, 0, 0.4), 0 10px 3px rgba(0, 0, 0, 0.1), inset 0px 0px 6px 3px rgba(0, 0, 0, 0.1), 0 -0.5px 3px rgba(0, 0, 0, 0.1);
}

h1 {
  font-size: 6em; 
}

h2 {
  font-size: 4em;
}

h3 {
  font-size: 1.5em;
}

/* fahrenheit and celsius buttons customization*/
input {
  width: 100px;
  height: auto;
}

.textBetweenImg {
  display: inline;
  padding-right: 20px;
  padding-left: 20px;
  position: relative;
  bottom: 40px;
}

footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  top: 1300px;
  padding: 1rem;
  text-align: center;
  color: black;
}

/* icons configuration */
.icon {
  position: relative;
  display: inline-block;
  width: 12em;
  height: 10em;
  font-size: 0.25em; /* control icon size here */
}

div.hide {
  display: none;
}

.cloud {
  position: absolute;
  z-index: 1;
  top: 50%;
  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: 50%;
  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: 50%;
  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: 50%;
  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: 50%;
  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: 50%;
  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: 50%;
  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;
  }
}

/* cloud animations */
.cloud-intro{
  position: relative;
  height: 100%;
  background: url(https://static.radulescu.me/examples/clouds/clouds1000.png);
  background: url(https://static.radulescu.me/examples/clouds/clouds1000.png) 0 200px,
              url(https://static.radulescu.me/examples/clouds/clouds1200_1.png) 0 300px,
              url(https://static.radulescu.me/examples/clouds/clouds1000_blur3.png) 100px 250px;
	animation: wind 20s linear infinite;
}
/* control the speed of the clouds here */
@keyframes wind{
  0% {
    background-position: 0 100px, 0 200px, 50px 150px;
  }
  100% {
    background-position: 1000px 100px, 1600px 200px, 900px 150px;
  }
}

/*mobile screens */
@media (max-width: 800px) and (min-width: 300px) {
  h1 {
    font-size: 3em;
  }
  h2 {
    font-size: 2.5em;
  }
  h3 {
    font-size: 1.1em;
  }
  input {
    width: 80px;
    height: auto;
  }
  body {
    height: 1100px;
  }
  footer {
    top: 1020px;
  }
  .locationContainer {
    height: 80px;
  }
}





            
          
!
            
              var api = "https://fcc-weather-api.glitch.me/api/current?";

$(document).ready(function() {
  $("#getWeather").on("click", function() {
    /* make Check Weather button disappear when clicked */
    document.getElementById("getWeather").style.display = "none";
    /* get the user's consent to use his/her location */
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function (position) {
        var lat = "lat=" + position.coords.latitude;
        var long = "lon=" + position.coords.longitude;
        var urlString = api + lat + '&' + long;
        getWeather(urlString);
        getLocation();
        $("div.locationContainer").removeClass("hide");
        $("div.cloud-intro").css("height", "60%");
      });
    } else {
      $("#error").append("Unable to retrieve location. Change or update browser version");
      console.log("Geolocation is not supported for this browser.")
    }
  }); //end getWeather function
  
   function getLocation() {
      $.ajax({
        url: "https://ipinfo.io/", dataType: "json", success: function (result) {
          $("#location").append(result.city + " " + result.country); 
        }  
      });
   }
  
});

function getWeather(urlString) {
  $.ajax({
    url: urlString,  dataType: "json", success: function (result) {
      var temp = result.main.temp.toFixed(1);
      $("#temp").append(temp);
      $("#tempUnit").append(String.fromCharCode(176) + "C");
      $("#description").append(result.weather[0].main + " ");
      var weatherCondition = result.weather[0].main;
      getIcon(weatherCondition);
      getBackground(weatherCondition);
    }
  });
}

function getIcon(condition) {
  var condition = condition.toLowerCase()
  switch (condition) {
    case "drizzle":
      setIcon(condition);
      break;
    case "clouds":
      setIcon(condition);
      break;
    case "rain":
      setIcon(condition);
      $("div.cloud-intro").removeClass("cloud-intro");
      break;
    case "snow":
      setIcon(condition);
      $("div.cloud-intro").removeClass("cloud-intro");
      break;
    case "clear":
      setIcon(condition);
      $("div.cloud-intro").removeClass("cloud-intro");
      break;
    case "thunderstorm":
      setIcon(condition);
      $("div.cloud-intro").removeClass("cloud-intro");
      break;
    default:
      setIcon(clouds);
      break;
  }
}

function setIcon(condition) {
  //find the right icon by searching for a specific class name 
  $("div." + condition).removeClass("hide");
}

function getBackground(condition) {
  var condition = condition.toLowerCase();
  switch (condition) {
      
    case "clear": 
      $("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/clear.jpg?raw=true)");
      break;
      
    case "clouds":
      $("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/clouds.jpg?raw=true)");
      $("body").css("color", "black");
      break;
      
    case "drizzle":
      $("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/drizzle.jpg?raw=true)");
      break;
      
    case "rain":
      $("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/rain.jpg?raw=true)");;
      break;
      
    case "snow":
      $("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/snow.jpg?raw=true)");
      $("body").css("color", "black");
      break;
      
    case "thunderstorm":
      $("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/thunderstorm.jpg?raw=true)");
      break;
  }
}

/* if toFahrenheit button is clicked, temp is converted into celsius */
$("#toFahrenheit").on("click", function () {
  var tempUnit = $("#tempUnit").text();
  if(tempUnit === (String.fromCharCode(176) + "C")) {
    var temp = $("#temp").text();
    temp = (temp * 9 / 5 + 32).toFixed(1);
    $("#temp").text(temp);
    $("#tempUnit").text(String.fromCharCode(176) + "F");
  }  
});

/* if toCelsius button is clicked, temp is converted into fahrenheit */
$("#toCelsius").on("click", function () {
  var tempUnit = $("#tempUnit").text();
  if(tempUnit === (String.fromCharCode(176) + "F")) {
    var temp = $("#temp").text();
    temp = (((temp - 32) * 5) / 9 ).toFixed(1);
    $("#temp").text(temp);
    $("#tempUnit").text(String.fromCharCode(176) + "C");
  }
});


            
          
!
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