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 dataPlacard">
    <div class="gridCity">City</div>
    <div class="gridIcon">Icon</div>
    <div class="gridCond">Condition</div>
    <div class="gridTemp">Temp</div>
    <div class="gridWind">Wind</div>
    <div class="gridHumid">Humid</div>
  </div>
</body>
              
            
!

CSS

              
                body {
  background-image: url("https://static.pexels.com/photos/125457/pexels-photo-125457.jpeg");
  background-size: 100vw 100vh
}

.dataPlacard {
  margin: auto;
  margin-top: 16px;
  border-radius: 10px;
  background-color: rgb(255, 255, 255, 0.5);
  width: 50vw;
  display: grid;
  grid-gap: 5px;
  grid-template-areas:
    'city city'
    'icon condition'
    'temp wind'
    'humidity humidity';
}

.dataPlacard div {
  text-align: center;
}

.gridCity {grid-area: city;}
.gridIcon {grid-area: icon;}
.gridCond {grid-area: condition;}
.gridTemp {grid-area: temp;}
.gridWind {grid-area: wind;}
.gridHumid {grid-area: humidity;}
              
            
!

JS

              
                var tempC;
var tempF;
var humidity;
var windMPH;
var windKPH;
var state;
var city;
var country;
var icon;
var latitude;
var longitude;

$(document).ready(function() {
  var api = "https://freegeoip.net/json/";

  $.getJSON(api, function(data) {
    longitude = data.longitude;
    latitude = data.latitude;
    country = data.country_name;
    city = data.city;
    state = data.region_name;
    zip = data.zip_code;

    $.getJSON(
      "https://api.apixu.com/v1/current.json?key=9332ab2c8ebc4235a2c183219180501&q=" +
        city,
      function(data2) {
        tempC = data2.current.temp_c;
        tempF = data2.current.temp_f;
        humidity = data2.current.humidity;
        windMPH = data2.current.wind_mph;
        windKPH = data2.current.wind_kph;
        icon = data2.current.condition.icon;
        currentCon = data2.current.condition.text;

        $(".gridCity").html("You are in: " + city);
        $(".gridIcon").html(`<img src=${icon}>`);
        $(".gridCond").html("Current Condition: " + currentCon);
        $(".gridTemp").html(`${tempC}&deg;C`);
        $(".gridHumid").html("Humidity: " + humidity);
        $(".gridWind").html("Wind: " + windKPH +" km/h");

        var unitToggle = true;
        
        $(".gridTemp, .gridWind").click(function() {
          if (unitToggle===true) {
            $(".gridTemp").html(`${tempF}&deg;F`);
            $(".gridWind").html("Wind: " + windMPH + "mph");
            unitToggle=false;
          } else {
            $(".gridTemp").html(`${tempC}&deg;C`);
            $(".gridWind").html("Wind: " + windKPH + "km/h");
            unitToggle=true;
          }
          
      });
    });
  });
});

//I coded this with assistance from Dylan Israel's tutorial which can be found here: https://www.youtube.com/watch?v=eLK28VPJvCE&t=1s
              
            
!
999px

Console