123

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.

            
              <div class="container-table">
   <div class="jumbotron vertical-center">
      <div class="container">
         <div id="city-div">
            <h3 class="city"></h3>
         </div>
         <label class="switch">
            <input id="check" type="checkbox">
            <div class="slider round"></div>
         </label>
         <p class="switch-c"> Units </p>
         <div class="row first-row">
            <div class="col-xs-3">
            </div>
            <div class="col-xs-2 text-center">
               <div class="row">
                  <div class="col-xs-12">
                     <img class="small-icons" id="temperature-current">
                  </div>
                  <div class="col-xs-12">
                     <h4 id="temperature-current-text"></h4>
                  </div>
               </div>
            </div>
            <div class="col-xs-2 text-center">
               <div>
                  <img id="current-image">
               </div>
            </div>
            <div class="col-xs-2 text-center">
               <div class="row">
                  <div class="col-xs-12">
                     <img class="small-icons" id="windspeed">
                  </div>
                  <div class="col-xs-12">
                     <h4 id="windspeed-text"></h4>
                  </div>
               </div>
            </div>
         </div>
         <div class="row text-center">
            <div class="col-xs-5">
            </div>
            <div class="col-xs-2">
               <div>
                  <h4 id="weather"></h4>
               </div>
            </div>
         </div>
         <hr class="style-two">
         <div class="row bottom-row">
            <div class="col-xs-4 text-center">
               <div>
                  <h4 id="day1"></h4>
                  <img class="icons" id="day1-image">
                  <p class="temps" id="temp-day1"></p>
                  <p class="pop" id="pop-day1"></p>
               </div>
            </div>
            <div class="col-xs-4 text-center">
               <div>
                  <h4 id="day2"></h4>
                  <img class="icons" id="day2-image">
                  <p class="temps" id="temp-day2"></p>
                  <p class="pop" id="pop-day2"></p>
               </div>
            </div>
            <div class="col-xs-4 text-center">
               <div>
                  <h4 id="day3"></h4>
                  <img class="icons" id="day3-image">
                  <p class="temps" id="temp-day3"></p>
                  <p class="pop" id="pop-day3"></p>
               </div>
            </div>
         </div>
      </div>
   </div>
   <p id="demo1"></p></br><p id="demo2"></p>
</div>
            
          
!
            
              html {
   height: 100%;
}
body {
   background-size: cover;
   -webkit-background-size: cover;
   -moz-background-size: cover;
}
.container-table {
   height: 100%;
   display: table;
}
.vertical-center {
  position: absolute;
  top: 50%;
  left:50%;
  transform: translate(-50%,-50%);
  border-radius: 5px;
  opacity: 0.8;
  box-shadow: 2px 2px 6px black;
  padding-bottom: 0;
}
#city-div {
   margin-top: -35px;
}
.icons {
   height: 100px;
}
.small-icons {
   height: 60px;
}
#current-image {
   height: 120px;
}
.temps {
   font-family: Arial,sans-serif;
   margin-top: 10px;
}
p.temps, p.pop {
   font-size: 16px;
}
p.pop {
   margin-top: -10px;
}
p.pop:before {
   content: "\f043";
   font-family: FontAwesome;
}
hr.style-two { 
   border: 0; 
   height: 1px; 
   background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0)); 
   margin-top: 50px;
}
.first-row {
   height: 120px;
   margin-top: 35px;
}
.jumbotron, .container, .container-table {
   min-width: 970px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
  float: right;
  margin-right: 100px;
  margin-top: -38px;
}
.switch-c {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 32px;
  float: right;
  margin-right: -71px;
}
.container p {
   font-size: 16px;
}

/* Hide default HTML checkbox */
.switch input {display:none;}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}
            
          
!
            
              $(function() {
   showPosition();

   $(window).resize(function() {
      if ($(window).width() < 768) {
         $(".first-row").addClass("text-center");
         $("#city-div").css("margin", "0");
      } else {
         $(".first-row").removeClass("text-center");
         $("#city-div").css("margin-left", "10%");
      }
   })
});

function showPosition() {

   var key = "ef01ade93512cff3";
   var weatherLookup = "https://api.wunderground.com/api/" + key + "/conditions/forecast/geolookup/q/autoip.json";

   $.ajax({
      url: weatherLookup,
      dataType: "json",
      success: function(parsed_json) {

         var location_city = parsed_json['location']['city'];
         var location_state = parsed_json['location']['state'];
         var country = parsed_json['location']['country_iso3166'];
         var weather = parsed_json['current_observation']['weather'];
         var forecast_standard = parsed_json['forecast']['txt_forecast']['forecastday'][0]['fcttext'];
         var forecast_metric = parsed_json['forecast']['txt_forecast']['forecastday'][0]['fcttext_metric'];
         var weather = parsed_json['current_observation']['weather'];
         var currentTemp_F = parsed_json['current_observation']['temp_f'];
         var currentTemp_C = parsed_json['current_observation']['temp_c'];
         var wind_mph = parsed_json['current_observation']['wind_mph'];
         var wind_kph = parsed_json['current_observation']['wind_kph'];
         var nt_test = parsed_json['current_observation']['icon_url'];
         var future_icon1 = parsed_json['forecast']['txt_forecast']['forecastday'][2]['icon'];
         var future_day1 = parsed_json['forecast']['txt_forecast']['forecastday'][2]['title'];
         var future_icon2 = parsed_json['forecast']['txt_forecast']['forecastday'][4]['icon'];
         var future_day2 = parsed_json['forecast']['txt_forecast']['forecastday'][4]['title'];
         var future_icon3 = parsed_json['forecast']['txt_forecast']['forecastday'][6]['icon'];
         var future_day3 = parsed_json['forecast']['txt_forecast']['forecastday'][6]['title'];
         var current_icon = parsed_json['current_observation']['icon'];
         var temp_day1FHigh = parsed_json['forecast']['simpleforecast']['forecastday'][1]['high']['fahrenheit'];
         var temp_day1FLow = parsed_json['forecast']['simpleforecast']['forecastday'][1]['low']['fahrenheit'];
         var temp_day1CHigh = parsed_json['forecast']['simpleforecast']['forecastday'][1]['high']['celsius'];
         var temp_day1CLow = parsed_json['forecast']['simpleforecast']['forecastday'][1]['low']['celsius'];
         var pop_day1 = parsed_json['forecast']['simpleforecast']['forecastday'][1]['pop'];
         var temp_day2FHigh = parsed_json['forecast']['simpleforecast']['forecastday'][2]['high']['fahrenheit'];
         var temp_day2FLow = parsed_json['forecast']['simpleforecast']['forecastday'][2]['low']['fahrenheit'];
         var temp_day2CHigh = parsed_json['forecast']['simpleforecast']['forecastday'][2]['high']['celsius'];
         var temp_day2CLow = parsed_json['forecast']['simpleforecast']['forecastday'][2]['low']['celsius'];
         var pop_day2 = parsed_json['forecast']['simpleforecast']['forecastday'][2]['pop'];
         var temp_day3FHigh = parsed_json['forecast']['simpleforecast']['forecastday'][3]['high']['fahrenheit'];
         var temp_day3FLow = parsed_json['forecast']['simpleforecast']['forecastday'][3]['low']['fahrenheit'];
         var temp_day3CHigh = parsed_json['forecast']['simpleforecast']['forecastday'][3]['high']['celsius'];
         var temp_day3CLow = parsed_json['forecast']['simpleforecast']['forecastday'][3]['low']['celsius'];
         var pop_day3 = parsed_json['forecast']['simpleforecast']['forecastday'][3]['pop'];
         var current_tempF = parsed_json['current_observation']['temp_f'];
         var current_tempC = parsed_json['current_observation']['temp_c'];
         var current_windspeedMPH = parsed_json['current_observation']['wind_mph'];
         var current_windspeedKPH = parsed_json['current_observation']['wind_kph'];
         
         if (country === "US"){
            $("#temperature-current-text").html(Math.round(current_tempF) + " F");
            $("#windspeed-text").html(Math.round(current_windspeedMPH)+" mph");
            $("#temp-day1").html(temp_day1FHigh + " - " + temp_day1FLow + " F");
            $("#temp-day2").html(temp_day2FHigh + " - " + temp_day2FLow + " F");
            $("#temp-day3").html(temp_day3FHigh + " - " + temp_day3FLow + " F");
            $(".city").html(location_city + ", " + location_state);
         } else {
            $("#temperature-current-text").html(Math.round(current_tempC) + " C");
            $("#windspeed-text").html(Math.round(current_windspeedKPH)+" kph");
            $("#temp-day1").html(temp_day1CHigh + " - " + temp_day1CLow + " C");
            $("#temp-day2").html(temp_day2CHigh + " - " + temp_day2CLow + " C");
            $("#temp-day3").html(temp_day3CHigh + " - " + temp_day3CLow + " C");
            $(".city").html(location_city + ", " + country);
         }
         
         if (country === "US") {
               $(".city").html(location_city + ", " + location_state);
            } else {
               $(".city").html(location_city + ", " + country);
            }
         
         $("#check").click(function() {
            if ($(this).prop("checked")){
               if (country === "US") {
                  $("#temperature-current-text").html(Math.round(current_tempC) + " C");
                  $("#windspeed-text").html(Math.round(current_windspeedKPH)+" kph");
                  $("#temp-day1").html(temp_day1CHigh + " - " + temp_day1CLow + " C");
                  $("#temp-day2").html(temp_day2CHigh + " - " + temp_day2CLow + " C");
                  $("#temp-day3").html(temp_day3CHigh + " - " + temp_day3CLow + " C"); 
               }
               else {
                  $("#temperature-current-text").html(Math.round(current_tempF) + " F");
                  $("#windspeed-text").html(Math.round(current_windspeedMPH)+" mph");
                  $("#temp-day1").html(temp_day1FHigh + " - " + temp_day1FLow + " F");
                  $("#temp-day2").html(temp_day2FHigh + " - " + temp_day2FLow + " F");
                  $("#temp-day3").html(temp_day3FHigh + " - " + temp_day3FLow + " F");
               }
               
            } else {
               if (country === "US") {
                  $("#temperature-current-text").html(Math.round(current_tempF) + " F");
                  $("#windspeed-text").html(Math.round(current_windspeedMPH)+" mph");
                  $("#temp-day1").html(temp_day1FHigh + " - " + temp_day1FLow + " F");
                  $("#temp-day2").html(temp_day2FHigh + " - " + temp_day2FLow + " F");
                  $("#temp-day3").html(temp_day3FHigh + " - " + temp_day3FLow + " F");
               }
               else {
                  $("#temperature-current-text").html(Math.round(current_tempC) + " C");
                  $("#windspeed-text").html(Math.round(current_windspeedKPH)+" kph");
                  $("#temp-day1").html(temp_day1CHigh + " - " + temp_day1CLow + " C");
                  $("#temp-day2").html(temp_day2CHigh + " - " + temp_day2CLow + " C");
                  $("#temp-day3").html(temp_day3CHigh + " - " + temp_day3CLow + " C"); 
               }
            }
         });
                           
         $("#temperature-current").attr("src","http://image.flaticon.com/icons/svg/134/134125.svg");
         $("#windspeed").attr("src","http://image.flaticon.com/icons/svg/134/134118.svg");
         
         if (nt_test.includes("nt_")){
            current_icon = "nt_" + current_icon;
         }
         
         $("#day1").html(future_day1);
         $("#day2").html(future_day2);
         $("#day3").html(future_day3);
         
         $("#pop-day1").html(" " + pop_day1 + "%");
         $("#pop-day2").html(" " + pop_day2 + "%");
         $("#pop-day3").html(" " + pop_day3 + "%");         
         
         $("#weather").html(weather);
         
         $("body").css("background-image", "url("+getPicture(current_icon)+")")
         $("#current-image").attr("src",getIcon(current_icon))
         $("#day1-image").attr("src",getIcon(future_icon1))
         $("#day2-image").attr("src",getIcon(future_icon2))
         $("#day3-image").attr("src",getIcon(future_icon3))

         function getIcon(icon) {
            switch (icon) {
               case "chancerain":
               case "chancesleet":
               case "nt_chancerain":
               case "nt_chancesleet":
               case "rain":
               case "sleet":
               case "nt_sleet":
               case "nt_rain":
                  return "http://image.flaticon.com/icons/svg/134/134136.svg";
                  break;
               case "chancesnow":
               case "chanceflurries":
               case "nt_chancesnow":
               case "nt_chanceflurries":
               case "nt_flurries":
               case "nt_snow":
               case "snow":
               case "flurries":
                  return "http://image.flaticon.com/icons/svg/134/134128.svg";
                  break;
               case "chancetstorms":
               case "nt_chancetstorms":
               case "nt_tstorms":
               case "tstorms":
                  return "http://image.flaticon.com/icons/svg/134/134137.svg";
                  break;
               case "clear":
               case "sunny":
                  return "http://image.flaticon.com/icons/svg/134/134123.svg";
                  break;
               case "cloudy":
               case "mostlycloudy":
                  return "http://image.flaticon.com/icons/svg/134/134132.svg";
                  break;
               case "fog":
               case "hazy":
                  return "http://image.flaticon.com/icons/svg/134/134120.svg";
                  break;
               case "nt_fog":
               case "nt_hazy":
                  return "http://image.flaticon.com/icons/svg/134/134120.svg";
                  break;
               case "mostlysunny":
               case "partlycloudy":
               case "partlysunny":
                  return "http://image.flaticon.com/icons/svg/134/134112.svg";
                  break;
               case "nt_mostlycloudy":
               case "nt_mostlysunny":
               case "nt_partlycloudy":
               case "nt_partlysunny":
                  return "http://image.flaticon.com/icons/svg/134/134115.svg";
                  break;
               case "nt_clear":
               case "nt_sunny":
                  return "http://image.flaticon.com/icons/svg/134/134114.svg";
                  break;
               case "":
                  break;
            }
         }
         function getPicture(picture) {
            switch (picture) {
               case "nt_sleet":
               case "nt_rain":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/Rain-on-glass-wallpaper-full-HD_zpsancymmr7.jpg";
                  break;
               case "rain":
               case "sleet":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/water-rain-raindrops-drops_zpsvofseoon.jpg";
                  break;
               case "flurries":
               case "snow":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/snowing_zpsz6mt8kqo.jpg";
                  break;
               case "nt_flurries":
               case "nt_snow":
                  return "http://www.daz3d.com/forums/uploads/FileUpload/37/eaf50268a7b93c4bb635ef3edcf4c6.png";
                  break;
               case "tstorms":
               case "nt_tstorms":
                  return "http://cdn.pcwallart.com/images/thunderstorm-wallpaper-2.jpg";
                  break;
               case "clear":
               case "sunny":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/1920x1080_sunny-days_zpsqnd2duqc.jpg";
               case "cloudy":
               case "mostlycloudy":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/In-the-very-midst-of-the-masses_zpsavnlh0zw.jpg";
               case "fog":
               case "hazy":
                  return "http://7-themes.com/data_images/out/26/6856125-fog-wallpaper.jpg";
                  break;
               case "nt_fog":
               case "nt_hazy":
                  return "http://7-themes.com/data_images/out/7/6790274-fog-wallpapers.jpg";
                  break;
               case "mostlysunny":
               case "partlycloudy":
               case "partlysunny":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/Appearance_of_sky_for_weather_forecast_Dhaka_Bangladesh_zpsrtuub2wy.jpg";
               case "nt_clear":
               case "nt_sunny":
                  return "http://www.imgbase.info/images/safe-wallpapers/photography/sky/22779_sky_night_sky.jpg";
                  break;
               case "nt_cloudy":
               case "nt_mostlycloudy":
               case "nt_partlycloudy":
               case "nt_partlysunny":
                  return "http://i1244.photobucket.com/albums/gg569/thinktwice84/UltraDynamicSky_Screenshot_05-1920x1080-36d465cae5dafa240f749df13b5bbbfe_zpsvlhyg1me.jpg";
                  break;
               case "":
                  break;
            }
         }
      }
   });
}
            
          
!
999px
🕑 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.

Console