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.


  <main class="container-fluid page-header row no-bottom-border rounded well well-info">
    <div class="col-xs-6 col-md-4 row margin-left">
      <div class="well rounded">
        <h1 id="place" class="bg-primary rounded text-center"> </h1>
        <ul class="text-center list-unstyled">
          <li> Latitudes:
            <span id="place-latitude" class="text-left"> </span>
            <span id="place-longitude" class="text-left"></span>
            <span id="weather-description" class="text-left"></span>
          <li class="">Temperature:
            <span class="text-left">
                      <span id="temperature">25</span>
            <span id="temp-unit">°C</span>
      <button id="convertCF" class="celsius btn btn-success btn-lg rounded text-rigth">
                Want some Fahrenheit?
    <div id="image" class="col-xs-6  col-md-8 row rounded">


                * {
  border-bottom: 0

.margin-left {
  margin-left: 1em !important;
.rounded {
  border-radius: 100%

.page-header {
  margin-top: 65px;

.well-info {
  background-color: #5bc0de;

.no-bottom-border {
  border-bottom: none !important;

.padded {
  padding: 3em;


 *          name: getweather.js
 *        Author: Christian Pujol,
 *   description:
 *   get weather information

var api = "";
var apiKey = "&APPID=87ab6be1ff3b6a47311724895d1086b4";

var weatherImg = {
  "01d": "clear-sky-day.jpg",
  "01n": "clear-sky-night.jpg",
  "02d": "few-cloud-day.jpg",
  "02n": "few-cloud-night.jpg",
  "03d": "scattered-clouds-day.jpg",
  "03n": "scattered-clouds-night.jpg",
  "04d": "broken-cloud-day.jpg",
  "04n": "broken-cloud-night.jpg",
  "09d": "rain-day.jpg",
  "09n": "rain-night.jpg",
  "10d": "rain-day.jpg",
  "10n": "rain-night.jpg",
  "11d": "thunderstorm-day.jpg",
  "11n": "thunderstorm-night.jpg",
  "13d": "snow-day.jpg",
  "13n": "snow-night.jpg",
  "50d": "mist-day.jpg",
  "50n": "mist-nigth.jpg"

function getweather(url) {
  $.getJSON(url, function(json) {

    $("#place").html( + '<img src="' +[0].icon + '.png">');

    var temp = (json.main.temp - 273.15).toFixed(2);


    // set background image
    $("#image").html('<img class="img-responsive rounded" src="img/' + weatherImg[[0].icon] + '" alt="' + weatherImg[[0].icon] + '">');



function geoSucces(pos) {
  var lat = pos.coords.latitude;
  var lon = pos.coords.longitude;
  var url = api + "lat=" + lat + "&lon=" + lon + apiKey;

function geoError() {
  $.getJSON("", function(json) {
    var pos = {};
    pos.coords = {};
    var coords = json.loc.split(',');
    pos.coords.latitude = coords[0];
    pos.coords.longitude = coords[1];


$(document).ready(function() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(geoSucces, geoError);
  } else {

  /* Toggle Celsius to Fahrenheit */
  $("#convertCF").on("click", function() {
    var temperature = $("#temperature").text();
    if ($(this).hasClass("celsius")) {

      $(this).text("Want some Celsius?");
      temperature = (temperature * 9 / 5 + 32).toFixed(1);

    } else if ($(this).hasClass("fahrenheit")) {

      $(this).text("Want some Fahrenheit?");
      temperature = ((temperature - 32) * 5 / 9).toFixed(1);