Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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 class="center shadow-1 j-blue white">
  <div class="dt mw6 center">
    <h2 class="dtc v-mid ph1">Today:</h2>
    <div class="dtc v-mid">
      <img class='mw5 br3 ba bg-white b--black h3 w3' id="main-icon" />
    </div>
    <div class="dtc v-mid pl3">
      <p id="location"></p>
      <p class='f6' id="date"></p>
      <p id="desc"></p>
    </div>
  </div>
</div>

<ul class="pl0 mt0 mw7 center">
</ul>

<a class="f5 no-underline black bg-animate hover-bg-black hover-white inline-flex items-center pa3 ba border-box" data-role='imperial' id="switch-btn">Switch to Metric</a>

<a href="https://www.wunderground.com" target="_blank"><img src="https://icons.wxug.com/logos/JPG/wundergroundLogo_4c_horz.jpg" alt="WeatherUnderground" class="logo" /></a>

  
              
            
!

CSS

              
                .j-blue {
  background-color: #3A506B;
}

.j-steel-blue {
  background-color: #517096
}

body {
  background-color: #FCFCFC;
}
.logo {
  width:120px;
}
              
            
!

JS

              
                function getLocation() {
  $.getJSON('https://ipapi.co/json/', function(data) {
    var city = data.city;
    var region = data.region;
    getWeather(city, region);
  });
}

function getWeather(city, region) {
  if ($('#switch-btn').data("role") === "imperial") {
    setWeather('f')
  } else {
    $('#switch-btn').text("Switch to Imperial");
    setWeather('c')
  }

  function setWeather(m) {
    $('ul').empty();
    var weatherURL = 'https://api.wunderground.com/api/d6146a43ef046da2/forecast/q/' + region + '/' + city + '.json';
    var desc,
      icon,
      date;
    $.getJSON(weatherURL, function(data) {
      var simpleData = data.forecast.simpleforecast.forecastday[0];
      var textData = data.forecast.txt_forecast.forecastday[0];
      if (m === 'f') {
        desc = textData.fcttext;
      } else {
        desc = textData.fcttext_metric;
      }
      date = simpleData.date.pretty;
      // Setting the Main Text
      $('#main-icon').attr('src', simpleData.icon_url);
      $('#location').text(city + ", " + region);
      $('#date').text(date);
      $('#desc').text(desc);
      // sets the list forecast
      for (x = 1; x < 7; x++) {
        textData = data.forecast.txt_forecast.forecastday[x];
        icon = textData.icon_url;
        // sets to either imperial or metric
        if (m === 'f') {
          desc = textData.fcttext;
        } else {
          desc = textData.fcttext_metric;
        }
        var day = textData.title;
        if (x === 0)
          return;
        $('ul').append("<li class='flex items-center lh-copy pa3 ph0-l bb b--black-10'> <img class='w2 h2 w3-ns h3-ns br-100' src=" + icon + " /> <div class = 'pl3 flex-auto' ><span class='f6 db black-70'>" + desc + "</span> </div> <div><a class='f6 link blue hover-dark-gray'>" + day + "</a> </div> </li>")
      }
    })
  }
}

$(document).ready(function() {
  getLocation();
  $('#switch-btn').click(function() {
    if ($(this).data('role') === 'imperial') {
      $(this).text("Switch to Imperial")
      $(this).data('role', 'metric')
      getLocation();
    } else {
      $(this).text("Switch to Metric")
      $(this).data('role', 'imperial')
      getLocation();
    }
  })
})
              
            
!
999px

Console