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


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.


                <link href="" rel="stylesheet">

<link href="" rel="stylesheet">

<!-- imported assets above this line-->

Set the background img as class and switch them with the js classList
  <div class="header">
  <h1>Local Weather App</h1>
  <div class="container">
    <div class="location">
  <h3>Country: <span class="country"></span></h3>
  <h3>City: <span class="city"></span></h3>
  <div class="information">
<p>Forecast: <span class="weather"></span><img class="icon"></img></p>
<p>Temperature: <span class="temp"></span> <span class="unit"></span></p>
<p>Wind Speed: <span class="wind"></span> knots</p>
    <button class="btn btn-success">C° to F°</button>

<p class="trial"></p>


                body {
  /*background-color: #d5d2d8;*/
background-color: #fff; 
linear-gradient(90deg, transparent 79px, #abced4 79px, #abced4 81px, transparent 81px),
linear-gradient(#eee .1em, transparent .1em);
background-size: 100% 1.2em;

h1 {
  margin: 0;
  padding: 17px 0;
  text-transform: uppercase;
  color: #272828;
  background-color: #fcec37;
  box-shadow: 3px 2px 15px #272728;
  font-family: 'Abril Fatface', cursive;
  letter-spacing: 0.4em;
  font-weight: 700;

.information {
  font-size: 20px;
  font-family: "helvetica";
  color: black;

.container {
  margin-left: 38%;
  margin-top: 2%

  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  color: black;

.information {
  margin-top: 32px;
  font-family: 'Poppins', sans-serif;

.btn {
  margin: 25px 7%;


                var temperature = document.querySelector(".btn");
var units = document.querySelector(".unit");

//make btn toggle between C° to F°

temperature.addEventListener("click", function(){
if(temperature.innerHTML === "C° to F°"){
    temperature.textContent = "F° to C°"    
  } else {
    temperature.textContent = "C° to F°"

//toggle temperature measurement units

temperature.addEventListener("click",       function(){

      if(temperature.innerHTML === "C° to F°"){
   units.textContent = "C°"    
   } else {
    units.textContent = "F°"

units.textContent = "C°"

//obtain user's geolocation

   if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = {
              lat: position.coords.latitude,
              lng: position.coords.longitude
            var latitude =;
            var longitude = pos.lng;            

//receive data from Weather JSON API

$(document).ready(function() {
  $.getJSON(''+ latitude + '&lon='+ longitude, function(json){

var newTemp = $(".temp");
var units = $(".unit");
var measurement = units[0].innerHTML;
//render the JSON response into HTML
//country information
var country =;
var coun = $(".country");
//city information
var city =;
var cit = $(".city");

//weather report
//wind speed in nautical miles

//toggle temperature C° into F° and vice versa

var celsius = json.main.temp;
var fahr = celsius * 9 / 5 + 32;

$(temperature).click(function (){
  if(units[0].innerHTML === "C°") { newTemp.text(celsius)
} else {
//icon properties depending on weather

var image =[0].icon;
$(".icon").attr("src", image);