Pen Settings

HTML

CSS

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

JavaScript

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

Behavior

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              <center><h1 id = "title">WeatherCaster</h1></center>
<div class="container">
  <center><h2 id = "location"></h2></center>
<center><img src = "#" id = "testimg" class='img-responsive'></center>
  <center><p id = "temperature"></p></center>
</div>
<center><ul>
    <li><p class = "ListItem" id = "celsius">Celsius</p></li>
    <li><p class = "ListItem" id = "fahrenheit">Fahrenheit</p></li>
    </ul></center>

            
          
!

CSS

            
              @import 'https://fonts.googleapis.com/css?family=Oswald';

body {
  background-size : 100%;
}

.container {
  background-color : #ffffff;
  opacity : 0.4;
  margin-left : 38vw;
  margin-right: 38vw;
}

#title {
  color : #ffffff;
  font-family : 'Oswald', sans-serif;
  font-size : 15vh;
}

#temperature {
  font-family : 'Oswald', sans-serif;
  font-size : 11.625vh;
  color : #333333;
}

#description {
  
  font-family : 'Oswald', sans-serif;
  font-size : 3.75;
  color : #333333;
  opacity : 0.7;
  
}

#location {
  color : #333333;
  padding-top : 4.125vh;
  padding-bottom : -10.375vh;
  font-family : 'Oswald', sans-serif;
  font-size : 6.625vh;
}

ul {
  list-style-type : none;
  margin : 0;
  padding : 0;
}

#celsius {
  float: left;
}
#fahrenheit {
  float: right;
}


.ListItem {
  display : block;
  padding : 1.625vh;
  background-color : rgba(255, 255, 255, 0.6);
  color : #333333;
  cursor : pointer;
}

li .ListItem:hover {
  background-color : rgba(255, 255, 255, 1.0);
}
            
          
!

JS

            
              $( document ).ready(function() { //Calling the IP API
  $.ajax ({url : "https://ipinfo.io/json"
    }).done(function(data) {
      Weather(data.city);
    }).fail(function(err) {
      console.log(err);
  });

});

function Weather(city){
  console.log(city);
$.ajax ({ //Calling the weather API
  dataType : "json",
  url : "https://api.apixu.com/v1/current.json?key=b40d2ff7016f4fdaa57184104170307&q=" + city,
  type : "GET"
}).done(function(json){
  var currentWeather = json.current.condition.code;
  var currentText = json.current.condition.text;
  var Location = json.location.name + ' , ' + json.location.country;
  var ico;
  var Celsius = json.current.temp_c;
  var Fahrenheit = json.current.temp_f;
  var Temperature = Fahrenheit;
  var TemperatureString = Temperature.toString() + "°"; 
  
  //Setting the html elements
  
  $("#location").html(Location);
  $("#temperature").html(TemperatureString);
  
  $("#celsius").on("click", function(){ //Turning temperature to celcius on button click
  Temperature = Celsius;
  TemperatureString = Temperature.toString() + "°"; 
  $("#temperature").html(TemperatureString);
       });
  
  $("#fahrenheit").on("click", function(){ //Turning temperature to fahrenheit on button click
  Temperature = Fahrenheit;
  TemperatureString = Temperature.toString() + "°"; 
  $("#temperature").html(TemperatureString);
       });
  
  //Initializing images
  
  if(currentWeather == 1000){ //Clear weather
    if(currentText = 'Clear'){ //Night
      var ico = "https://cdn.pbrd.co/images/GzfIGmg.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image', 'url(https://cdn.pbrd.co/images/GzfLitL.jpg)');
      console.log("works!");
    }else{ //Day
      var ico = "https://cdn.pbrd.co/images/GzfIrBn.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfL0an.jpg)');
    }
  }
  
  if(currentWeather == 1003){ //Few Clouds
      var ico = "https://cdn.pbrd.co/images/GzfITIN.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfLtD7.jpg)' );
  }
  
  if(currentWeather == 1006){ //Scattered Clouds
   
      var ico = "https://cdn.pbrd.co/images/GzfJHO5.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfMoN0.jpg)' );
  }
  
  if(currentWeather == 1009){ //Overcast
   
      var ico = "https://cdn.pbrd.co/images/GzfI816.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfKMJt.jpg)');
  }
  
  if(currentWeather == 1063 || currentWeather == 1150 || currentWeather == 1180 || currentWeather == 1186 || currentWeather == 1192 || currentWeather == 1240 || currentWeather == 1243 || currentWeather == 1246 || currentWeather == 1249 || currentWeather == 1252 || currentWeather == 1261 || currentWeather == 1264){ //Shower Rain
   
      var ico = "https://cdn.pbrd.co/images/GzfJSlp.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfMDVH.jpg)');
  }
  
    if(currentWeather == 1069 || currentWeather == 1072 || currentWeather == 1153 || currentWeather == 1168 || currentWeather == 1171 || currentWeather == 1183 || currentWeather == 1189 || currentWeather == 1195 || currentWeather == 1198 || currentWeather == 1201 || currentWeather == 1204 || currentWeather == 1207 || currentWeather == 1237){ //Rain
   
      var ico = "https://cdn.pbrd.co/images/GzfJueI.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfM9h2.jpg)');
  }
  
     if(currentWeather == 1087 || currentWeather == 1273 || currentWeather == 1276 || currentWeather == 1279 || currentWeather == 1282){ //Thunderstorm
   
      var ico = "https://cdn.pbrd.co/images/GzfKaeF.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfN6Hi.jpg)' );
  }
  
     if(currentWeather == 1066 || currentWeather == 1114 || currentWeather == 1117 || currentWeather == 1210 || currentWeather == 1213 || currentWeather == 1216 || currentWeather == 1219 || currentWeather == 1222 || currentWeather == 1225 || currentWeather == 1255 || currentWeather == 1258){ //Snow
   
      var ico = "https://cdn.pbrd.co/images/GzfK1X7.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfMWMz.jpg)' );
  }
  
     if(currentWeather == 1030 || currentWeather == 1135 || currentWeather == 1147){ //Mist
   
      var ico = "https://cdn.pbrd.co/images/GzfJgrT.png";
      document.getElementById("testimg").setAttribute("src" , ico);
      $('body').css('background-image' , 'url(https://cdn.pbrd.co/images/GzfLTEu.jpg)');
  }
  
  
  
});
  
}










            
          
!
999px

Console