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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 class="container">
    <h1 id="location" class="text-white">The Current Weather in</h1>
    <div id="result">
          <div class="row">
            <div class="col-md-3 col-sm-2 col-xs-1"></div>
            <div class="col-md-6 col-sm-8 col-xs-10">
              <div class=""><img src="" alt="weather icon" id="icon" style="width;100px"></div>
              <div class="mb-2 p-2 rounded box text-white text-shadow" id="desc"></div>
              <div class="my-2 p-2 rounded box text-white text-shadow" id="temp">Temp</i></div>
            <div class="my-2 p-2  rounded box text-white text-shadow" id="wind">Wind</i></div>
            <button class="btn rounded box text-white text-shadow" id="convert">Convert Temp</button>
            <div class="col-md-3 col-sm-2 col-xs-1"></div>


                body {
  position: relative;
  background: none;
  font-family: Montserrat, sans-serif;
html {

  background-image: url("");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  height: 100%;


.container {

  text-align: center;
  margin-top: 150px;
  width: 450px;

h1 {

  text-shadow: 4px 4px 10px #000;


#headerTxt {
  color: black;

#desc {

  width: 70px;

.box {
  background-color: rgba(37, 162, 183, 0.6);
  box-shadow: 3px 3px 5px black;

.text-shadow {
  text-shadow: 2px 2px 4px #000;



                $(document).ready(function() {
  // Declare global lat and lon variables 
  // Setting variables due to unreliable geolocation calls
  var lat = 42.9563768;
  var lon = 1.921991;
  lat = lat.toFixed(2);
  lon = lon.toFixed(2);
  $.getJSON("" + lat + "&lon=" + lon, function(json) {
    // $("#weather").html(JSON.stringify(json));
    $("#location").append(" " +;
    $("#desc").append(" " +[0].description);
    $("#temp").append(" " + Math.round(json.main.temp) + "&deg;C");
    $("#wind").append(" " + json.wind.speed + "mph " + degToCompass(json.wind.deg));
    // return json;

function getPosition() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      lat = position.coords.latitude;
      lon = position.coords.longitude;
      $("#data").html("latitude: " + lat + "<br>longitude: " + position.coords.longitude);   

function degToCompass(num) {
    var val = Math.floor((num / 22.5) + 0.5);
    var arr = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"];
    return arr[(val % 16)];

var unit = "c"

$("#convert").on("click", function(){
  if (unit === "c") {
    var tempCStr = document.getElementById("temp").innerHTML;
    var tempC = parseFloat(tempCStr.match(/-?(?:\d+(?:\.\d*)?|\.\d+)/)[0])     
    var tempF =  Math.round(tempC*9/5 + 32);
    $("#temp").html("Temp " + tempF + "&deg;F");
    unit = "f"
  } else if (unit === "f"){
    var tempFStr = document.getElementById("temp").innerHTML;
    var tempF = parseFloat(tempFStr.match(/-?(?:\d+(?:\.\d*)?|\.\d+)/)[0])     
    var tempC =  Math.round((tempF - 32)*5/9);
    $("#temp").html("Temp " + tempC + "&deg;C");
    unit = "c"