Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.



<div class="container" id="white-box">
  <div class="row">
    <div class="col-12-lg" id="city-state">
      <h1 id="location"> Location </h1>
  <div class="row">
    <div class="col-lg-12" id="temperature">
      <h2 id="temp"> 75 C </h2>
      <button class="btn btn-primary" id="temp-btn"> Fahrenheit </button>
  <div class="row">
    <div class="col-lg-12">
      <h2 id="weather-type"> Type of Weather </h2>


                body {
  background-image: url("");
  background-size: 100% 100%;
  background-repeat: no-repeat;
html {
  height: 100%;
  width: 100%;

#white-box {
  background-color: white;
  border: 2px solid black;
  border-radius: 15px;
  width: 700px;
  height: auto;
  opacity: .8;
  margin: 5%;
  position: center;
#city-state {
  margin-top: 40px;
#temp-btn {
  background: linear-gradient(to bottom, #3b679e 0%,#2b88d9 50%,#207cca 51%,#7db9e8 100%); 
  font-weight: bold;
  border: 1px solid black;
  border-radius: 3px;
  padding: 5px;



  $.getJSON("", function(location){ 
    var longitude = location.lon;
    var latitude =;
    var weatherAPI = "" + latitude + "&lon=" + longitude + "&appid=b96bf580e977f1da5008ec06d6e06cd4"
    $.getJSON(weatherAPI, function(obj){ 
      var celsius = obj.main.temp - 273;
      //Change weather info on page
      $("#location").html( + ", " +;
      $("#temp").html(Math.round(celsius) + " C")
      //Change from celsius to fahrenheight and back
      var currentDegree = "C";
        var fahrenheit = celsius * 9/5 + 32;
        if (currentDegree === "C") {
          currentDegree = "F";
          $("#temp").text(Math.round(fahrenheit) + " F");
        } else {
          currentDegree = "C";
          $("#temp").text(Math.round((fahrenheit - 32)/1.8) + " C");
        }//Close if
      })//Close btn .click function
      //Change background according to weather
      switch ([0].icon) {
        case "11d": 
          $("body").css("background-image", "url('')");
        case "09d":
          $("body").css("background-image", "url('')");
        case "10d":
          $("body").css("background-image", "url('')");
        case "13d":
          $("body").css("background-image", "url('')");
        case "50d":
          $("body").css("background-image", "url('')");
        case "01d":
        case "01n":
          $("body").css("background-image", "url('')");
        case "03d":
        case "04d":
        case "03n":
          $("body").css("background-image", "url('')");
      }// Close switch

    }); // Close .getJSON
    }); // Close getCurrentPosition
}); //Close document ready