cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <h5 class='text-center'>Local Weather Widget</h5>

<h6 class='text-center'>Here is your local weather for today</h6>

<div id="iconTemp">
  <div class="col-md-6" id="icon"></div>
  <div class="col-md-6" id="temp"></div>
</div>

<div class='weather-wrap row'>
  <div class='location col-md-4'></div>
  <div class='conditions col-md-4'></div>
  <div class='wind col-md-4'></div>
</div>
<br/>
<button class='btn btn-primary btnF' id="convertF">Convert to Fahrenheit</button>
<button class='btn btn-primary btnC' id="convertC">Convert to Celceius</button>
<br/>
<footer>
<div class='footer '>
  <div class='footer-text'>
    <p>Created by <a href='http://joseph.michael-chambers.com/'>Joseph Chambers</a>
  </div>
</div>
  <footer>
            
          
!
            
              html {
  height: 100%;
}

body {
  text-align: center;
  background: no-repeat;
  background-size: cover;
}

h1 {
  text-shadow: 1px 2px 3px rgba(0, 0, 0, .4);
  font-size: 3em;
  padding: 1%
}

h5 {
  color: white;
  text-shadow: 1px 2px 3px rgba(0, 0, 0, .4);
  font-size: 3em;
  padding: 1%
}

h6 {
  text-shadow: 0 0 0.2em #000;
  color: white;
  font-size: 1em;
}

#icon {
  text-align: right;
}

#temp {
  color: white;
  text-shadow: 0 0 0.2em #000;
  font-size: 2.5em;
  font-weight: bold;
  text-align: left;
}

.location {
  position: ;
  font-size: 1.3em;
  font-weight: bold;
  padding-top: 10px;
  color: blue;
  text-shadow: 0 0 0.2em #333;
  background: white;
  height: 100px;
  width: 200px;
  margin: 8px;
  border-radius: 4px;
  text-align: center;
  opacity: 0.5;
  -webkit-box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
}

.location:hover {
  opacity: .8;
}

.conditions {
  position: ;
  font-size: 1.3em;
  font-weight: bold;
  padding-top: 6%;
  color: blue;
  text-shadow: 0 0 0.2em #333;
  background: white;
  height: 100px;
  width: 200px;
  margin: 8px;
  border-radius: 4px;
  text-align: center;
  opacity: 0.5;
  -webkit-box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
}

.conditions:hover {
  opacity: .8;
}

.wind {
  position: ;
  font-size: 1.3em;
  font-weight: bold;
  padding-top: 6%;
  color: blue;
  text-shadow: 0 0 0.2em #333;
  background: white;
  height: 100px;
  width: 200px;
  margin: 8px;
  border-radius: 4px;
  text-align: center;
  opacity: 0.5;
  -webkit-box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 0px 15px -2px rgba(0, 0, 0, 0.75);
}

.wind:hover {
  opacity: .8;
}

#convertF {
  display: visible;
}

#convertC {
  display: none;
}

.row {
  display: inline-block;
}

.footer {
   color: white;
  text-align: center;
  position: relative;
 
  text-shadow: 0 0 0.2em #000;
  font-size: 1em;
  padding: 1%;
}

p {}
            
          
!
            
              //main load weather function
function loadWeather() {
  var City, State, Dir, IP, IP_Info;
  var latitude, longitude, weatherUrl2;
  var Units = 'C';
  //gets IP

  //gets location based on ip
  $.getJSON(
    'http://ipinfo.io',
    function(loc) {
      IP = loc.ip;
      IP_Info = 'http://ipinfo.io/' + IP;

      $.getJSON(
        'http://ipinfo.io/' + loc.ip,
        function(location) {
          City = location.city;
          State = location.region;
          $('.location').append('Location: ' + City + ', ').append(State);
          var weatherUrl = 'http://api.openweathermap.org/data/2.5/weather?q=' +
            City +
            '&units=metric&APPID=b712b386a2d044d53f71ff581397682e';

          // gets conditions based on openweathermap api
          $.get(
            weatherUrl,
            function(conditions) {
              if (conditions.wind.deg >= 20 && conditions.wind.deg <= 60)
                Dir = 'NE';
              if (conditions.wind.deg >= 61 && conditions.wind.deg <= 120)
                Dir = 'E';
              if (conditions.wind.deg >= 121 && conditions.wind.deg <= 160)
                Dir = 'SE';
              if (conditions.wind.deg >= 161 && conditions.wind.deg <= 200)
                Dir = 'S';
              if (conditions.wind.deg >= 241 && conditions.wind.deg <= 285)
                Dir = 'SW';
              if (conditions.wind.deg >= 286 && conditions.wind.deg <= 340)
                Dir = 'SW';
              if (conditions.wind.deg <= 20) Dir = 'N';

              //generate icon based on API data
              $('#icon').prepend(
                '<img src="http://openweathermap.org/img/w/' +
                  conditions.weather[0].icon +
                  '.png" alt="weather icon class="img-responsive" />'
              );

              $('#temp').append(conditions.main.temp + ' ' + Units);
              $('.conditions').append(
                'Weather: ' + conditions.weather[0].description
              );
              $('.wind').append(
                'Wind:' + conditions.wind.speed + ' knots ' + Dir
              );

              $('#convertF').click(function() {
                if (Units = 'C') Units = 'F';
                $('#temp').text(
                  parseInt(conditions.main.temp * 9 / 5 + 32) + ' ' + Units
                );
                $('#convertC').show();
                $('#convertF').hide();
              });
              $('#convertC').click(function() {
                if (Units = 'F')
                  Units = 'C'('#temp').text(
                    parseInt(conditions.main.temp - 32) + ' ' + Units
                  );
                $('#convertF').css('display', 'inline');
                $('#convertC').css('display', 'none');
              });
              // change background based on weather
              switch (conditions.weather[0].main) {
                case 'Rain':
                  $('body').css(
                    'background-image',
                    'url("https://terribleeker.files.wordpress.com/2010/05/may18-2010web-6.jpg")'
                  );
                  break;
                case 'Clouds':
                  $('body').css(
                    'background-image',
                    'url("https://unsplash.it/1200/800?image=84")'
                  );
                  break;
                case 'Clear':
                  $('body').css(
                    'background-image',
                    'url("https://snap-photos.s3.amazonaws.com/img-thumbs/960w/RVO75X4E0Z.jpg")'
                  );
                  break;
                case 'Snow':
                  $('body').css(
                    'background-image',
                    'url("https://stochasticobservations.files.wordpress.com/2009/12/dsc01319.jpg")'
                  );
                  break;
                case 'Mist':
                  $('body').css(
                    'background-image',
                    'url("http://indianhomemakerphotos.files.wordpress.com/2014/02/fog-2-highway.jpg")'
                  );
                  break;
                default:
                  $('body').css(
                    'background-image',
                    'url("https://unsplash.it/1200/800?image=85")'
                  );
              }
            },
            'json'
          );
        },
        'jsonp'
      );
    },
    'jsonp'
  );
}
$(document).ready(loadWeather);
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console