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. 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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="container-fluid text-center weather">
  <h1>Local Weather</h1>
  <!-- list of weather information to display -->
  <ul class="list-unstyled">
    <li id="location"></li>
    <li class="btn btn-default" id="temp"></li>
    <li  id="description"></li>
    <li id="icon"></li>
  <p>If this page does not load the weather, remove the https:// from your address bar. Also, may not work correctly in Safari.</p>
body {
  font-size: 18px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;

h1 {
  color: Blue;

ul {
  list-style: none;
  color: black;
  // declare variables
  var lati;
  var longi;  
  var name;
  var description;
  var temp;
  var farenheit;
  var celsius;
  var tempSwitch = false;
  var icon;
  // gets location based on ip address
    lati =;
    longi = data.lon;
    // sends lat and lot to getData method
    getData(lati, longi);
  function getData(lati, longi) {
    var api = ''+lati+'&lon='+longi+'&appid=27fee676035d13ce03a3e92c472d2594';
    // gets weather information based on lat and long passed in.
    // assigns returned data to variables
      name =;
      description =[0].description;
      temp = data.main.temp;
      farenheit = ((temp)*(9/5)-459.67).toFixed(2);
      celsius = (temp - 273).toFixed(2);
      //sends info to displayData to display it on the screen.
      displayData(name, description, temp, farenheit, celsius);
  function displayData(name, description, temp, farenheit, celsius){
    $("#temp").html(farenheit + " F");
    // based on weather description, sets different backgrounds
      case "clear sky":
        $('body').css('background-image', 'url(');
      case "few clouds":
        $('body').css('background-image', 'url(');
      case "scattered clouds":
        $('body').css('background-image', 'url(');
      case "broken clouds":
        $('body').css('background-image', 'url(');
      case "shower rain":
        $('body').css('background-image', 'url(');
      case "rain":
        $('body').css('background-image', 'url(');
      case "thunderstorm":
        $('body').css('background-image', 'url(');
      case "snow":
        $('body').css('background-image', 'url(');
      case "mist":
        $('body').css('background-image', 'url(');
    // clicking on the temp switches between Fahrenheit and celsius
      if(tempSwitch === false){
        $("#temp").html(celsius + " C");
        tempSwitch = true;
    else {
      $("#temp").html(farenheit + " F");
      tempSwitch = false;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.