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 text-center">
    <h1 id="headline">Steven's Weather App</h1>
    <figure>
      <canvas id="icon1"></canvas>
    </figure>
    <main class="container">
      <div class="paper">
        <div><h1 id="current-country"></h1></div>
      <div><h2 id="current-location">Getting Location...</h2></div>
      <div id="weather-description"></div>
      <div id="local-temperature"></div>
      <div id="high-temp"></div>
      <div id="low-temp"></div>
      </div>
      <button class="btn-primary" id="cfButton">Toggle Celcius/Fahrenheit</button>
    </main>
    <footer class="fixed-bottom">
      <a href="https://codepen.io/dreamsniper/" target="_blank"><i class="fa fa-codepen fa-2x" aria-hidden="true"></i></a>
      <a href="https://www.facebook.com/steven.taveras1" target="_blank"><i class="fa fa-facebook-official fa-2x" aria-hidden="true"></i></a>
      <a href="https://twitter.com/TheDreamsniper" target="_blank"><i class="fa fa-twitter-square fa-2x" aria-hidden="true"></i></a>
      <a href="https://github.com/dreamsniper" target="_blank"><i class="fa fa-github-square fa-2x" aria-hidden="true"></i></a>
      <a href="https://www.linkedin.com/in/steven-taveras-81475b75/" target="_blank"><i class="fa fa-linkedin-square fa-2x" aria-hidden="true"></i></a>
      <a href="https://plus.google.com/u/0/+StevenTaveras_dreamsniper" target="_blank"><i class="fa fa-google-plus-square fa-2x" aria-hidden="true"></i></a>
      <a href="https://www.youtube.com/channel/UCFVYSh4PC84c34Etdagmc1Q" target="_blank"><i class="fa fa-youtube-square fa-2x" aria-hidden="true"></i></a>
      <a href="https://forum.freecodecamp.com/users/dreamsniper/summary" target="_blank"><i class="fa fa-free-code-camp fa-2x" aria-hidden="true"></i></a>
      <p>Copyright &copy; 2017 Steven Taveras</p>
    </footer>
  </div>
  <script src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>
</body>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Days+One|Open+Sans:400,800");

$font-stack: Days one, sans-serif;
$font-stack-2: Open sans, sans-serif;
* {
  box-sizing: border-box;
}
body {
  font-family: $font-stack;
  color: #fff;
  background-color: #b28cd9;
  background-repeat: no-repeat;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  background-position: center;
  figure {
    margin: 1em auto;
    canvas {
      width: 70%;
    }
  }
  main {
    font-family: $font-stack-2;
    width: 60%;
    background-color: rgba(254, 194, 5, 0.3);
    border-radius: 15px;
    padding: 1em;
    box-shadow: 0 15px 20px -15px rgba(0, 0, 0, 0.3),
      0 55px 50px -35px rgba(0, 0, 0, 0.3), 0 85px 60px -25px rgba(0, 0, 0, 0.1);
    .paper {
      background-color: rgba(255, 255, 255, 0.75);
      border-radius: 10px;
      padding: 1em;
      box-shadow: 0 15px 20px -15px rgba(0, 0, 0, 0.3),
        0 55px 50px -35px rgba(0, 0, 0, 0.3),
        0 85px 60px -25px rgba(0, 0, 0, 0.1);
      @media only screen and (min-width: 768px) {
      /* Styles */
      position: relative;
    }
    }
    #current-location,
    #current-country {
      font-weight: 800;
      text-shadow: 2px 2px 4px #000000;
      /* Smartphones (portrait and landscape) ----------- */
      @media only screen and (max-width: 440px) {
        /* Styles */
        font-size: 11pt;
      }
    }
    #weather-description {
      font-family: $font-stack;
      font-size: 15pt;
      letter-spacing: 0.21em;
      color: orange;
      text-shadow: 2px 2px 4px #000000;
    }
    #local-temperature {
      font-weight: 800;
      font-size: 20pt;
      text-shadow: 2px 2px 4px #000000;
      @media only screen and (min-width: 768px) {
        /* Styles */
        position: absolute;
        top: 1em;
        left: .5em;
        font-size: 40pt;
      }
    }
    #high-temp{
      color: #000;
       @media only screen and (min-width: 768px) {
        /* Styles */
        position: absolute;
        bottom: 1em;
        right: 1em;
        font-size: 20pt;
      }
    }
    #low-temp {
      color: #000;
       @media only screen and (min-width: 768px) {
        /* Styles */
        position: absolute;
        top: 1em;
        right: 1em;
        font-size: 20pt;
      }
    }
  }
  button {
    margin: 1em auto;
  }
  footer {
    margin-top: 100%;
    a {
      color: #fff;
    }
  }
}

              
            
!

JS

              
                //openweathermap api-key
var API_KEY = "4f76f229391709106c3c44b33312c811";
var units = "imperial";
var JSON_URL =
  "https://api.openweathermap.org/data/2.5/weather?units=" + units +"&lat=";

//jquery wrapper where most of logic will take place
$(function() {
  'use strict';
  //to store location
  var location;

  //google geolocation for latitude and longitude
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      location = {
        lat: position.coords.latitude,
        lon: position.coords.longitude
      };

      //call to the weather api
      $.getJSON(
        JSON_URL + location.lat + "&lon=" + location.lon + "&APPID=" + API_KEY,
        function(wd) {
          var currentLocation = wd.name;
          var currentCountry = wd.sys.country;
          var currentWeather = wd.weather[0].description;
          var currentTemperature = wd.main.temp;
          var currentHigh = wd.main.temp_max;
          var currentLow = wd.main.temp_min;
          var iconCode = wd.weather[0].icon;

          //update html
          $("#current-country").html(currentCountry);
          $("#current-location").html(currentLocation);
          $("#weather-description").html(currentWeather);
          $("#local-temperature").html(
            "<p>" + currentTemperature + " &#8457;</p>"
          );
          $("#high-temp").html(
            "<p>High/ " + currentHigh + " &#8457;</p>"
          );
          $("#low-temp").html("<p>Low/ " + currentLow + " &#8457;</p>");

          //create skycons
          var skycons = new Skycons({ color: "orange" });

          function weatherIcon() {
            'use strict';
            if (currentWeather === "clear sky" && iconCode === "01d") {
              skycons.add("icon1", Skycons.CLEAR_DAY);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/b664kszn7/blue-sky-299764_1920.jpg)"
              );
            } else if (currentWeather === "clear sky" && iconCode === "01n") {
              skycons.add("icon1", Skycons.CLEAR_NIGHT);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/toah51hf7/lake-927433_1920.jpg)"
              );
            } else if (currentWeather === "rain" || currentWeather === "light rain" || currentWeather === "heavy intensity rain") {
              skycons.add("icon1", Skycons.RAIN);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/6pdrm4lf7/rain-455120_1920.jpg)"
              );
            } else if (currentWeather === "snow" || currentWeather === "light snow") {
              skycons.add("icon1", Skycons.SNOW);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/bpft7tgfn/snowflake-554635_1920.jpg)"
              );
            } else if (currentWeather === "sleet" || currentWeather === "haze") {
              skycons.add("icon1", Skycons.SLEET);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/4aqhffuk3/hailstones-on-window-pane-1354038_1920.jpg)"
              );
            } else if (currentWeather === "windy") {
              skycons.add("icon1", Skycons.WIND);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/jxhqst8c3/grass-1810493_1920.jpg)"
              );
            } else if (currentWeather === "fog" || currentWeather === "mist") {
              skycons.add("icon1", Skycons.FOG);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/x2x8yx27n/fog-571786_1920.jpg)"
              );
            } else if (currentWeather === "scattered clouds" || currentWeather === "broken clouds") {
              skycons.add("icon1", Skycons.CLOUDY);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/ebvbor7n7/clouds-314476_1280.jpg)"
              );
            } else if (currentWeather === "few clouds") {
              skycons.add("icon1", Skycons.PARTLY_CLOUDY_DAY);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/e0dvbzr77/sky-592415_1920.jpg)"
              );
            } else if (currentWeather === "overcast clouds") {
              skycons.add("icon1", Skycons.PARTLY_CLOUDY_NIGHT);
              $("body").css(
                "background-image",
                "url(https://s19.postimg.cc/v26pe362b/month-2219843_1920.jpg)"
              );
            } else {
              $("#icon").html("<h2>Sorry no matching weather icon</h2>");
            }
            skycons.play();
          }
          weatherIcon();

          //toggle celcius and farenheit
          var celsius = Math.floor((currentTemperature - 32) * (5 / 9));
          var celsiusHigh = Math.floor((currentHigh - 32) * (5 / 9));
          var celsiusLow = Math.floor((currentLow - 32) * (5 / 9));
          
            $("#cfButton").click(function() {
              if(units === "imperial"){
                units = "metric";
                $("#current-country").html(currentCountry);
                $("#local-temperature").html("<p>" + celsius + " &#8451;</p>");
                $("#high-temp").html("<p>High/ " + celsiusHigh + " &#8451;</p>");
                $("#low-temp").html("<p>Low/ " + celsiusLow + " &#8451;</p>");
              }else if(units === "metric"){
                units = "imperial";
                $("#current-country").html(currentCountry);
                $("#local-temperature").html("<p>" + currentTemperature + " &#8457;</p>");
                $("#high-temp").html("<p>High/ " + currentHigh + " &#8457;</p>");
                $("#low-temp").html("<p>Low/ " + currentLow + " &#8457;</p>");
              }
            });
        }
      );
    });
  } else {
    $("#current-location").html("Your Browser does not support Geolocation");
  }
});

              
            
!
999px

Console