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


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 id="main" class="container-fluid">
  <div class="weather-box">
      <p id="location"></p>
      <img id="icon" class="img-responsive center-block">
      <p id="weather"></p>
      <p id="temp"></p>
      <button class="btn btn-primary center-block">To metric</button>
    <p>Page coded by Kevin Liu</p>


                #main {
  background-color: #111111;
  color: white;
  font-family: verdana;
  text-align: center;
  height: 100vh;

.weather-box {
  font-size: 250%;

#icon {
  margin: 0 auto;

p {
  text-align: center;

h1 {
  font-weight: bold;
  font-size: 250%;

footer {
  height: 150px;
  margin-top: 20px;
  padding: 20px;


                // TODO: add geolocation
// TODO: make linkBuilder function

var fahr = ' &deg;F';
var cels = ' &deg;C';
var tempF;
var tempC;
var locKeyLink;

// 0 for Imperial units, 1 for Metric units
var tempState = 0;

function linkBuilder() {
  var linkBase = "";
  // Probably here
  $.getJSON("", function(results) {
    locKeyLink = linkBase + "&lat=" + + "&lon=" + results.lon;

function getWeather() {
  $.getJSON(locKeyLink + "&units=imperial", function(results) {
    // Sets location data
    var location = + ", " +;
    // Sets weather display and corresponding icon
    var weather =[0].main;
    var icon = "" +[0].icon + ".png";
    $('#icon').attr('src', icon);
    $('#icon').attr('alt', 'Icon for ' + weather);
    // Sets temperature in Fahrenehit
    tempF = results.main.temp;
    $('#temp').html(tempF + fahr);
  // Store temperature in celsius in tempC
  $.getJSON(locKeyLink + "&units=metric", function(results) {
    tempC = results.main.temp;

// Switch to opposite units of measure
$('button').click(function() {
  switch (tempState) {
      // Change to metric
    case 0:
      $('#temp').html(tempC + cels);
      tempState = 1;
      $('button').html('To imperial');
      // Change to imperial
    case 1:
      $('#temp').html(tempF + fahr);
      tempState = 0;
      $('button').html('To metric');