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 flow-text">
  <div class="row">
    <div class="col s12 m6 offset-m3">
      <div class="card blue-grey lighten-1">
        <div class="card-content blue-grey-text text-lighten-5 center-align">
          <div id="latLong">LOCATION: </div>
          <div id="currentWeather">CONDITIONS: </div>
          <div id="icon"><canvas id="icon1" width="200" height="200"></canvas></div>
          <div id="temperature"><span id="tempText"></span><span id="tempUnits">F</span></div>
            <a class="waves-effect waves-light btn blue-grey lighten-4 blue-grey-text text-darken-2" id="FCButton">Switch C/F</a>
          <div class="divider"></div>
          <div class="center-align">
            <a class="waves-effect waves-light btn blue-grey lighten-4 blue-grey-text text-darken-2 activator">credits</a>
        <div class="card-reveal blue-grey darken-3 blue-grey-text text-lighten-5">
          <span class="card-title">CREDITS<i class="material-icons right">close</i></span></span>
          <p>By Andy Bonner, 2016</p>
          <p>for <a href="https://www.freecodecamp.com/challenges/show-the-local-weather">FreeCodeCamp</a></p>
          <p>Weather data is provided by the <a href="http://forecast.io/">Forecast.io</a> API, and the icons by their <a href="https://darkskyapp.github.io/skycons/">"Skycons."</a> Layout and DOM manipulation use <a href="http://materializecss.com/">Materialize</a>.
              body {
  background-attachment: fixed;
  background-repeat: no-repeat;
  background: blue;
  /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(#78909c, #263238) fixed;
  /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(#78909c, #263238) fixed;
  /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(#78909c, #263238) fixed;
  /* For Firefox 3.6 to 15 */
  background: linear-gradient(#78909c, #263238) fixed;
  /* Standard syntax */

.container {
  font-weight: bold;

.btn {
  margin: 4%;
              function getLocalWeather() {
  var lat, long;
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(success, error, geoOptions);
  } else {
    alert("Geolocation services are not supported by your web browser.");

  function success(position) {
    lat = position.coords.latitude.toFixed(5);
    long = position.coords.longitude.toFixed(5);
    getWeather(lat, long);
    $("#latLong").append(lat + "°, " + long + "°");

  function error(error) {
    alert("This app only works over a secure connection. Please add 'https://' to the beginning of the URL (i.e. 'https://codepen.io/AbdiViklas/pen/NrRxqx'). Error code and message: " + error.code + ": " + error.message);

  var geoOptions = {
    enableHighAccuracy: true,
    maximumAge: 30000,
    timeout: 27000

function getWeather(latitude, longitude) {
  $.getJSON("https://api.forecast.io/forecast/25dafa45c7e7aacbe25bdfd1dfbdc89e/" + latitude + "," + longitude + "?callback=?", function(data) {
    var conditions = data.currently.summary;
    var tempF = data.currently.temperature;
    var tempC = (tempF - 32) / 1.8
    var icon = data.currently.icon;
    var skycons = new Skycons({"color": "#f3e5f5"}); //this line generates the set of Skycons, and also changes the default color to a hint of purple
    skycons.set("icon1", icon); //this first points to the <canvas> element with ID "icon1," and the sets the var icon above to it
    skycons.play(); //and the animation starts!
    $("#tempText").text("TEMP: " + Math.round(tempF) + "°");
    $("#FCButton").click(function() {
      if ($("#tempUnits").text() === "F") {
        $("#tempText").text("TEMP: " + Math.round(tempC) + "°");
      } else {
        $("#tempText").text("TEMP: " + Math.round(tempF) + "°");

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