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


Add 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 or require. We'll also process your JavaScript with Babel.

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


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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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="row centered-form center-block">
  <div class="container col-md-8 col-md-offset-2">

    <div class="container-fluid myBackground">
      <h1 class="text-center">Weather Generator</h1>

      <div class="row">
        <div class="col-xs-4">
          <h1> You Are Here: </h1><span id="location"></span>
        <div class="col-xs-4">
          <h1> Temperature: </h1>
          <div><span id="temperature"></span>
            <span id="cel"></span>
            <button id="degrees">Switch Between Fahrenheit and Celcius</button>
        <div class="col-xs-4">
          <h1>Details: </h1> <span id="details"></span>
          <span id="icon"><img src=""></span>

    <!-- closes row -->
    <div class="footer text-center myBackground"> <em>Don't forget your umbrella...-Mike</em>
      <p>No data? Try loading using https instead of http.

              body {
  background-image: url("");
  background-color: blue;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  background-size: cover;
span {
  color: red;
  font-size: 28px;
h1 {
  font-family: Impact;
  color: brown;
  text-align: center;
button {
  font-size: 14px;
#cel {
  display: none;
#temperature {
  display: inline;
.myBackground {
  background-color: rgba(255, 255, 255, 0.5);
  color: inherit;

              var APPID = "5f208d5a783a7f02e9c53400957f8e3a",
  fah = "",
  celc = "",
  current = 1;
//Future updates:
//Make it responsive for mobile (for some reason it isn't working)
//Design updates to make it more like a widget
//Cooler weather icons, theirs are kind of lame.
//Kelvin option with a nuclear explosion background

$("#degrees").click(function() {
  if (current == 1) {
    $("#temperature").css("display", "none");
    $("#cel").css("display", "inline");
    current = 0;
  } else if (current == 0) {
    $("#temperature").css("display", "inline");
    $("#cel").css("display", "none");
    current = 1;

window.onload = function() {
  /* NEW */
  if (navigator.geolocation) {
    var showPosition = function(position) {
      updateByGeo(position.coords.latitude, position.coords.longitude);
  } else {
    var zip = window.prompt(
      "Could not discover your location. What is your zip code?"

  /* NEW */

  function updateByGeo(lat, lon) {
    var url =
      "" +
      "lat=" +
      lat +
      "&lon=" +
      lon +
      "&APPID=" +

  function updateByZip(zip) {
    var url =
      "" +
      "zip=" +
      zip +
      "&APPID=" +

  function sendRequest(url) {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        var data = JSON.parse(xmlhttp.responseText);
        var weather = {};
        weather.location =;
        weather.temp = K2F(data.main.temp);
        weather.celcius = K2C(data.main.temp);
        weather.main =[0].description;
        weather.icon =[0].icon;
    };"GET", url, true);
  function update(weather) {
      "" + weather.icon + ".png"
    fah = weather.temp;
    $("#location").html(weather.location + "<br />");
    $("#temperature").html(fah + "&deg F <br />");
    celc = weather.celcius;
    $("#cel").html(celc + "&deg C <br />");
    $("#details").html(weather.main + "<br />");
  //Switch to Fahrenheit
  function K2F(k) {
    return Math.round(k * (9 / 5) - 459.67);
  //Switch to Celcius
  function K2C(k) {
    return Math.round(k - 273.15);