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

              
                <div id="weatherbox">
  <div id="topbox">
    <span id="city"></span>
  </div>
  <div id="middlebox">
    <div id="midmid">
      <span><i id="currenticon"></i></span>
      <span id="temp"></span>
      <button class="fc">C</button>
    </div>
    <span id="desc"></span>
  </div>
  <div id="bottombox">
    <div class="bottomsides">
      <span><i class="wi wi-raindrop"></i></span>
      <span id="hum"></span>
    </div>
    <div class="bottomsides">
      <span><i class="wi wi-strong-wind"></i></span>
      <span id="wind"></span>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /* Stylesheet for Local Weather App */
@import url('https://fonts.googleapis.com/css?family=Montserrat');

html {
  height: 100%;
  background: linear-gradient(to right, #4ecdc4, #556270);
}

#weatherbox {
  border: 1px solid #FFFFFF;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 5vw;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  width: 300px;
  height: 350px;
}

#topbox {
  border-bottom: 1px #FFFFFF solid;
  height: 20%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 25px;
}

#middlebox {
  height: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: 'Montserrat', sans-serif;
}

#midmid {
  display: flex;
  flex-direction: row;
  align-items: center;
}

#bottombox {
  height: 30%;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  font-family: 'Montserrat', sans-serif;
}

.bottomsides {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.wi {
  width: 100%;
  font-size: 55px;
}

button {
  color: #FFFFFF;
  outline: none;
}

#temp {
  font-size: 75px;
  padding-left: 10px;
}

.fc {
  border: none;
  border-radius: 50%;
  font-size: 35px;
  height: 1.5em;
  width: 1.5em;
  text-align: center;
  text-decoration: none;
  background: none;
  cursor: pointer;
  padding: 0px;
}

.fc:hover {
  color: #FFFFFF;
  border: 1px solid #FFFFFF;
  /*color: #4C739B;
  background-color: #FFFFFF;*/
}

footer {
	position: fixed;
	bottom: 0;
	right: 0;
	left: 0;
	height: 5vw;
	background-color: #000000;
	z-index: 2;
}

#pagebottom {
	width: 100%;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	padding: 0px 10px;
}

#contact {
	margin: 0px 10px;
	padding: 0px 10px;
	color: #C1C1C1;
	font-family: sans-serif;
}

#social {
	display: flex;
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	padding-right: 10vw;
	height: 90%;
}

footer div a i {
  color: #C1C1C1;
	margin: 0px 10px;
}

footer div a i:hover {
	color: #B0D5A7;
}

              
            
!

JS

              
                // test.js

// JS for Local Weather App
$(document).ready(function() {
  var lat;
  var lon;
  var desc;
  var hum;
  var weatherid;
  var temp = [];
  var wind = [];

  // Request IP address from user to get location & store coordinates
  $.getJSON("https://ipapi.co/json", function(data) {
    //$("#city").html(data.city);
    lat = data.latitude;
    lon = data.longitude;

    // Get weather information
    // Need to add 'https://cors-anywhere.herokuapp.com/' before URL to have HTTPS using a CORS server
    $.getJSON(
      "https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat=" +
        lat +
        "&lon=" +
        lon +
        "&APPID=44762e241a2c3fc4f616e416abc08f0e",
      function(weatherData) {
        $("#city").html(weatherData.name);
        // Store temperates (celsius and fahrenheit)
        temp[0] = (weatherData.main.temp - 273.15).toFixed(0) + "&#176";
        temp[1] =
          ((weatherData.main.temp - 273.15) * 1.8 + 32).toFixed(0) + "&#176";

        // Store description, humidity, and wind
        desc = weatherData.weather[0].description;
        hum = weatherData.main.humidity + "%";

        // Store wind (km/h and mi/h)
        wind[0] = (weatherData.wind.speed * 3.6).toFixed(2) + " km/h";
        wind[1] = (weatherData.wind.speed * 2.23).toFixed(2) + " mi/h";

        // Store weather ID for icons; change icon depending on weather conditions
        weatherid = weatherData.weather[0].id;

        if (weatherid == 800) {
          $("#currenticon")
            .html('<i class="wi wi-day-sunny"</i>')
            .css({ color: "#FFE14A" });
        }

        var rainIcons = [
          300,
          301,
          302,
          310,
          311,
          312,
          313,
          314,
          321,
          500,
          501,
          502,
          503,
          504,
          511,
          520,
          521,
          522,
          531
        ];
        for (i = 0; i < rainIcons.length; i++) {
          if (weatherid == rainIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-rain"</i>')
              .css({ color: "#244A69" });
          }
        }

        var stormIcons = [200, 201, 202, 210, 211, 212, 221, 230, 231, 232];
        for (i = 0; i < stormIcons.length; i++) {
          if (weatherid == stormIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-storm-showers"></i>')
              .css({ color: "#244A69" });
          }
        }

        var cloudIcons = [801, 802, 803, 804];
        for (i = 0; i < cloudIcons.length; i++) {
          if (weatherid == cloudIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-cloudy"></i>')
              .css({ color: "#C1C1C1" });
          }
        }

        var snowIcons = [600, 601, 602, 611, 612, 615, 616, 620, 621, 622];
        for (i = 0; i < snowIcons.length; i++) {
          if (weatherid == snowIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-snow"></i>')
              .css({ color: "#FFFFFF" });
          }
        }

        var atmosphereIcons = [
          701,
          711,
          721,
          731,
          741,
          751,
          761,
          762,
          771,
          781
        ];
        for (i = 0; i < atmosphereIcons.length; i++) {
          if (weatherid == atmosphereIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-dust"></i>')
              .css({ color: "#C1C1C1" });
          }
        }

        var extremeIcons = [900, 901, 902, 903, 904, 905, 906];
        for (i = 0; i < extremeIcons.length; i++) {
          if (weatherid == extremeIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-storm-warning"></i>')
              .css({ color: "#FFFFFF" });
          }
        }

        var additionalIcons = [
          951,
          952,
          953,
          954,
          955,
          956,
          957,
          958,
          959,
          960,
          961,
          961
        ];
        for (i = 0; i < additionalIcons.length; i++) {
          if (weatherid == additionalIcons[i]) {
            $("#currenticon")
              .html('<i class="wi wi-hurricane-warning"></i>')
              .css({ color: "#FFFFFF" });
          }
        }

        // Insert weather info temp
        $("#temp").html(temp[0]);
        $("#desc").html(desc);
        $("#hum").html(hum);
        $("#wind").html(wind[0]);
      }
    );

    // Function to switch between units
    $(".fc").click(function() {
      if ($(".fc").text() === "F") {
        $(".fc").text("C");
        $("#temp").html(temp[0]);
        $("#wind").html(wind[0]);
      } else {
        $(".fc").text("F");
        $("#temp").html(temp[1]);
        $("#wind").html(wind[1]);
      }
    });

    // Switch weather icons based on description from API
    var weatherIcons = {
      sunny: ["wi-day-sunny", "#FFE14A"],
      cloudy: ["wi-cloudy", "#C1C1C1"],
      rainy: ["wi-rain", "#33436D"],
      storm: ["wi-storm-showers", "#33436D"],
      snow: ["wi-snow", "#FFFFFF"]
    };
  });
});

              
            
!
999px

Console