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.


                <!--Make page mobile responsive-->
<div class="container-fluid">
    <!--Create a header panel with centered text-->
    <div class="white-panel">
      <h1>Current Local Weather</h1>
    <!--Create a panel to display weather information-->
    <div class ="white-panel text-center">
      <!--Create a division to show user's nearest city-->
      <div class="city"></div>
      <!--Create a division to show a symbol representing the weather in the user's current location-->
      <div id="icon">
        <img src="#">
      <!--Create a division to show a description of the weather in the user's current location-->
      <div class="weather"></div>
      <!--Create a division to show the temperature in teh user's current location-->
      <div class="temp"></div>
      <!--Create a button to toggle between Celsius and Fahrenheit-->
      <button type="button" class="btn btn-default" id="units" title="Metric/Imperial">


                body {
  background-color: #000;
  padding-top: 6rem;
  font-family: Impact;

.container-fluid {
  display: flex;
  flex-direction: column;

.white-panel {
  background-color: #FFF;
  padding: 3rem;
  border-radius: 1rem;
  margin: 2rem auto;
  text-align: center;

h1 {
  margin: 0;
  display: inline;

.city {
  font-size: 250%;

.weather {
  font-size: 170%;

.temp {
  font-size: 170%;


                $(document).ready(function() {
  //Make Fahreneheit the default unit
  let fahrenheit = true;
  //Set up global temperature variables so they are accessible to the conversion button
  let celsiusTemp = 0;
  let fahrenheitTemp = 0;
  //Get location and weather information  
  $.getJSON("", response => {
    //Retrieve name of city from API response
    const city = response.cityName;
    //Split city name into an array
    const splitArray = city.split("");
    //Remove spaces from array
    const filteredArray = splitArray.filter(function(val) {
      return val != " ";
    //Rejoin characters
    const noSpaces = filteredArray.join("");
    //Turn array back into a string
    const cityString = noSpaces.toString();
    //Setup URL for weather API
    const url = "" + cityString + "&appid=02282750d865580915ab2d3c4dfc05a3";
    //Send request to weather API
    $.getJSON(url, data => {
      //Assign weather data to variables
      const weatherDescription =[0].description;
      const kelvinTemp = data.main.temp;
      //Convert Kelvin temperature to Celsius
      celsiusTemp = Math.round(kelvinTemp-273);
      //Convert Celsius temperature to Fahrenheit
      fahrenheitTemp = Math.round((celsiusTemp)*(9/5)+32);
      const icon =[0].icon;
      const iconUrl = "" + icon + ".png";
      //Display location and weather data
      $(".temp").text(fahrenheitTemp + "\u00b0 F" );
      $("#icon img").attr("src", iconUrl);
  //Set up button to toggle between Celsius and Fahrenheit
  $("#units").on("click", function() {
    if (fahrenheit === true) {
      $(".temp").text(celsiusTemp + "\u00b0 C");
      fahrenheit = false;
    else {
      $(".temp").text(fahrenheitTemp + "\u00b0 F");
      fahrenheit = true;