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.

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