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="grey-bg">
<div id="container">
<h2>
  Weather App</h2>
<p>Please allow access to location for this to work!</p>
<h3>Your coordinates:</h3>
<p id="lon">Longitude: </p>
<p id="lat">Latitude: </p>
  <p id="location"></p> 
<h3>Weather:</h3>
<img src="" id="icon"/>
<h5 id="weather"></h5>
<button id="temp"></button>
</div>
</div>
<div id="lol" align="center">Made by <a href="https://codepen.io/quantomistro/">quantomistro<a/>, 2018</div>
              
            
!

CSS

              
                .border {
  color: white;
  cursor: pointer;
  background-color: rgba(0,0,0,0);
}
#container {
  color: rgb(225,225,225);
  text-align: center;
  position: absolute;
  left: 170px;
  right: 170px;
  bottom: 0px;
  top: 0;
  padding-top: 15px;
  background-color: rgba(64,64,64,0.9);
  overflow: hidden;
}
.border:hover {
  background-color: white;
  border-color: white);
  color: black;
}
html { background: url("http://coastalinsight.com/wp-content/uploads/2014/08/DSC_3094-Edit2.jpg") no-repeat center fixed;
  background-size: cover;
}
.shadow {
  box-shadow: 3px 3px 4px rgba(0,0,0,0.6);
  border-style: solid;
  border-width: 0;
  border-radius: 3px;
  margin-bottom: 15px;
}
h2,
h3,
h5 {
  font-family: "Kaushan Script", sans-serif;
}
@keyframes zoom {
  0% {}
  100% {font-size: 2.5rem; color: white; text-shadow: 3px 3px 3px black;}
}
@keyframes zoom2 {
  0%{}
  100% {font-size: 125%; color: white; text-shadow: 3px 3px 3px black;}
}
h2:hover,
h3:hover,
h5:hover {
  animation-name: zoom;
  animation-duration: 0.5s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}
p:hover {
  animation-name: zoom2;
  animation-duration: 0.5s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;  
}
h2,h3,h5,p {
  cursor: default;
}
#lol {
  color: lightgrey;
  position: absolute;
  bottom: 0;
  left: 100px;
  right: 100px;
}
              
            
!

JS

              
                $(document).ready(function() {
  
  if (navigator.geolocation) {
    var lat, lon;
    navigator.geolocation.getCurrentPosition(
      function(position) {
        lat = position.coords.latitude;
        lon = position.coords.longitude;
        var fccurl =
          "https://fcc-weather-api.glitch.me/api/current?lat=" +
          lat +
          "&lon=" +
          lon;
        console.log(fccurl);
        $.get(fccurl)
          .done(function(data) {
            var arr = data.weather[0].description.split("");
            arr[0] = arr[0].toUpperCase();
            var descrip = arr.join("")
            var degF = data.main.temp * 9 / 5 + 32;
            $("#lon").html("Longitude: " + lon);
            $("#lat").html("Latitude: " + lat);
            $("#icon").attr("src", data.weather[0].icon);
            $("#icon").addClass("shadow")
            $("#weather").html(descrip);
            $("#temp").html(Math.round(data.main.temp) + "°C");
          $("#temp").addClass("border btn");  
          $("#temp").on("click", function() {
              if (
                $("#temp")
                  .html()
                  .substr(-1, 1) == "C"
              ) {
                $("#temp").html(Math.round(degF) + "°F");
              } else {
                $("#temp").html(Math.round(data.main.temp) + "°C");
              }
            });
          if (data.name != "") {
            $("#location").html("Location: " + data.name);
          }
          })
          .fail(function() {
            alert("Sorry, weather API request failed.");
          });
      },
      function() {
        alert("Sorry, geolocation request failed!");
      }
    );
  } else {
    alert("Sorry, geolocation is not supported by this browser!");
  }
});
              
            
!
999px

Console