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

              
                <body>
  <div class="container-fluid" id="main">
    <div class="box effect8">
      <div class="row" id="title">
        <h1>My Weather App</h1>
      </div>
      <div class="weather">
        <div class="row">
          <div class="col-lg-4">
            <h3>My Location</h3>
            <h2 id="city"></h2>
          </div>
          <div class="col-lg-4">
            <h3>Current Temperature</h3>
            <h2 class="fahrenheit" id="temp"></h2>
            <h2 class="celcius" id="temp2"></h2>
            <a class="btn btn-primary btn-lg" id="celcius" href="#" role="button"><h4>change to C&deg</h4></a>
          </div>
          <div class="col-lg-4">
            <h3>Forecast</h3>
            <h2 id="weather-icon"></h2>
          </div>
        </div>
      </div>
    </div>
  </div>
              
            
!

CSS

              
                h1,
h2,
h3,
h4,
h5,
h6,
p,
a {
  font-family: 'Open Sans', sans-serif;
  color: #003049
}

h3 {
  font-size: 20px;
}

.box {
  margin: 15% auto;
  background-color: #f0f0f0;
  width: 70%;
  padding: 50px;
  border-radius: 20px;
}

#title {
  margin-top: -75px;
  margin-bottom: 20px;
}

#title h1 {
  font-weight: 700;
  margin-top: 50px;
}

.weather {
  width: 100%;
  background-color: #fff;
  border: 2px solid #003049;
  border-radius: 15px;
  position: relative;
  -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.location h3,
.weather h3 {
  text-align: center;
  font-weight: 700;
}

.weather h2 {
  font-size: 48px;
  text-align: center !important;
  font-weight: 700;
}

.effect8 {
  position: relative;
  -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
  -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}

#main h1 {
  text-align: center;
  font-size: 60px;
}

.get-weather-button {
  display: block;
  clear: both;
  width: 100%;
  height: 150px;
}

#button{
  margin-top: 30px;
  height: 60px;
}

#button h4 {
  color: white;
  font-weight: 600;
  font-size: 24px;
}

#city {
  font-size: 48px;
  font-weight: 700;
  text-align: center;
}

#weather-icon h2 {
  display: block;
  font-size: 48px;
  font-weight: 700;
  text-align: center !important;
}

.wi {
  display: block;
}
#celcius{
  display: block;
  width: 60%;
  height: 30px;
  margin:  20px auto;
}
#celcius h4{
  margin-top: -5px;
  color: white;
  font-size: 16px;
  text-align: center;
}
              
            
!

JS

              
                $(document).ready(function() {

  navigator.geolocation.getCurrentPosition(function(position) {
    lat = position.coords.latitude;
    lon = position.coords.longitude;
    var temp;

    $.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=3c89384ec689ce22045d3aecd75a3a3e", function(json) {

      console.log(json);

      //Store the name of the location
      var locationName = json.name;
      $("#city").append(locationName);

      //Store the current weather status
      var weatherStatus = json.weather[0].description;
      $("#weather").append(weatherStatus);

      //Get weather ID for setting icon
      var weatherID = json.weather[0].id;

      //Setting the correct icon based on the ID
      //Thunderstorm
      if (weatherID >= 200 && weatherID < 235) {
        $("#weather-icon").addClass("wi").addClass("wi-thunderstorm");
      }
      //Light Showers
      if (weatherID >= 300 && weatherID < 325) {
        $("#weather-icon").addClass("wi").addClass("wi-showers");
      }
      //Rain
      if (weatherID >= 500 && weatherID < 535) {
        $("#weather-icon").addClass("wi").addClass("wi-rain");
      }
      //Snow
      else if (weatherID >= 600 && weatherID < 625) {
        $("#weather-icon").addClass("wi").addClass("wi-snow");
      }
      //Clear
      else if (weatherID == 800) {
        $("#weather-icon").addClass("wi").addClass("wi-day-sunny");
      }
      //Cloudy
      else if (weatherID >= 801 && weatherID < 810) {
        $("#weather-icon").addClass("wi").addClass("wi-cloudy");
      }

      //Temperature
      temp = (json.main.temp * (9/5)) - 459.67;
      $("#temp").append(temp.toFixed(0)).append("℉");
      
      var ctemp = (temp - 32) * (5/9);
      
     var toggle = true;
     $('#celcius').on('click',function() {
        //removed remove() here
        if(toggle) {
          $(this).closest("h2").append($(".fahrenheit").html(ctemp.toFixed(0) + "&degC"));
          $('#celcius').closest("a").append($("h4").html('change to F&deg'));
          toggle = false;
        }
        else {
          $(this).closest("h2").remove($(".fahrenheit").html(temp.toFixed(0) + "&degF"));
          $('#celcius').closest("a").append($("h4").html('change to C&deg'));
          toggle = false;
          toggle = true;
        } 
	});

      console.log(json.weather[0].description);

    });
  });
});

              
            
!
999px

Console