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.

            
              <div class='container-fluid'>
  <div class='location'>
  Weather  Location:
  </div>
  <div class=description></div>
  <div class='tempText'>Temperature<br>
  Click on Icon: °F/°C
  </div><br><br><br>
  <!--<div class='icon'></div>-->
<div class='row'>    
<div class='col-md-4'>
<img class='humidityIcon' src="http://calvarycentraloahu.com/codepen/rainCloud200.png" alt='humidity'>
<div class='humidity'>Humidity:
</div>
</div>

<div class='col-md-4'>
<div class='temp'>
<button class='btn btn-primary'>
</button>
 </div>
 </div>
  
<div class='col-md-4'>
<img class='windIcon'   src="http://calvarycentraloahu.com/codepen/windy200.jpg"
alt="Wind">
<div class='wind'>Wind:
      </div>
    </div>
  </div>
</div>
            
          
!
            
              body {
  font-family: "arial", tahoma;
  letter-spacing: 1px;
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  margin-bottom: 35px;
}

/* --- weather location --*/
.location {
  text-align: center;
  font-size: 3.5em;
  font-weight: bold;
  color: #148c12;
}

.description {
  text-align: center;
  line-height: 0;
  font-size: 2.75em;
  color: #FF0800;
  margin-top: 3%;
}
/* temp button*/
.btn {
  height: 75px;
  width: 125px;
  border: 3px solid #000;
  border-radius: 15%;
  background-color: #bcd6f2;
  color: #FF0800;
  font-weight: bold;
  font-size: 2.0em;
  text-align: center;
  margin-top: -130px;
}

.btn:focus {
  color: #FF0800;
  outline: none;
}

.temp {
  margin-top: 10%;
  text-align: center;
}

.tempText {
  text-align: center;
  margin-top: 2%;
  margin-bottom: 12%;
  font-size: 2.0em;
  font-weight: bold;
  color: #FF0800;
  padding-bottom: 0px;
  margin-bottom: -20px;
}


.humidity {
  font-size: 2.0em;
  text-align: center;
  color: #FF0800;
  font-weight: bold;
   margin-left: 95%;
}

.wind {
  font-size: 2.0em;
  text-align: center;
  color: #FF0800;
  font-weight: bold;
  margin-right: 70%;
}

.windIcon {
  margin-top: -5%;
  margin-left: -5%;
  border-radius: 20%;
  opacity: .9;
  height: 6.0em;
}

.humidityIcon {
  margin-top: -5%;
  margin-left: 90%;
  height: 7.5em;
}


            
          
!
            
              //https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
$(document).ready(function() {
  $('body').css('background-image', "url('')");
  //get and show location
  getLocation();

  function getLocation() {
    $.get("http://ipinfo.io", function(location) {
      console.log(location);
      $('.location').append(location.city + ", ").append(location.region);
      getWeather(location.loc);
    }, 'jsonp');
  }
  //get weather
  function getWeather(loc) {
    var lat = loc.split(",")[0];
    var lon = loc.split(",")[1];
    //var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + "&appid=9caef11b776d4c210cca3f8ebeba530c&units=" + unitDefault;
    var API_KEY = "0087cf6328ae7e22b636e954f877baea";

    var weatherApiUrl = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid=0087cf6328ae7e22b636e954f877baea&units=imperial";
    console.log(weatherApiUrl);

    $.get(weatherApiUrl, function(weather) {
      var temperature = weather.main.temp;
      temperature = ((temperature).toFixed(0));
      var humidity = weather.main.humidity;
      var description = weather.weather[0].description.toUpperCase()
      var wind = (weather.wind.speed).toFixed(1);
      var iconNum = weather.weather[0].icon;

      $('.icon').append("<img src='http://openweathermap.org/img/w/" + weather.weather[0].icon + ".png'>");
      $('.btn').html(temperature + '\xB0 F');

      $('.humidity').append(humidity + '%');
      $('.wind').append(wind + ' mph');
      $('.description').html(description);

      var png = ['01d', '01n', '02d', '02n', '03d', '03n', '04d', '04n', '09d', '09n', '10d', '10n', '11d', '11n', '13d', '13n', '50d', '50n'];
      var bodyImages = [ 
        /*01d-clearSkyDay*/
        'http://calvarycentraloahu.com/codepen/day_sky1000.jpg',
        
        /*01n-night_sky*/
        'http://calvarycentraloahu.com/codepen/night_sky1000.jpg',
        
        /*02d-fewCloudsDay*/
        'http://calvarycentraloahu.com/codepen/clouds1000.jpg',
        
        /*02n-scattered_clouds*/
        'http://calvarycentraloahu.com/codepen/scattered_clouds1000.jpg',
        
        /*03d-scatteredClouds*/                        
        'https://imgfave-chat-herokuapp-com.global.ssl.fastly.net/image_cache/1380845209393452_animate.gif',
        
        /*03n-night_clouds*/
        'http://calvarycentraloahu.com/codepen/night_clouds1000.jpg',
  
        /*04d-brokenCloudsDay*/
        'http://calvarycentraloahu.com/codepen/thick_clouds1000.jpg',
        
        /*04n night_clouds*/
        'http://calvarycentraloahu.com/codepen/night_clouds2.jpg', 
        
       /*09d-showerRainDay*/
        'http://calvarycentraloahu.com/codepen/raindrops_window1000.jpg',
        
        /*09n-rain_water*/
         'http://calvarycentraloahu.com/codepen/rainy_day.jpg',
        
        /*10d-rainDay*/
        'http://calvarycentraloahu.com/codepen/rain_water1000.jpg',
        
        /*10n-rain*/
         'http://calvarycentraloahu.com/codepen/rain_falling1000.jpg',
        
        /*11d-thunderstorm*/
        'http://calvarycentraloahu.com/codepen/storm_clouds.jpg',

        /*11n - thunder&lightning*/
        'http://calvarycentraloahu.com/codepen/lightning1000.jpg',
        
        /*13d-snowDay*/
       'http://calvarycentraloahu.com/codepen/snow.jpg',
        
        /*13n*/
        'https://49.media.tumblr.com/7303e0cd9158949a9c05b1e06d4770cb/tumblr_mxxr6md7aW1qzgikgo1_500.gif',
        /*50d-mist*/
        'https://secure.static.tumblr.com/cc2c3f18b2d43b0c26cf1a52b5833e46/p0o9m4o/HGInxida1/tumblr_static_f58e6imgxs84c0coc4g4ww0gc_640_v2.gif',
        /*50n*/
        'https://49.media.tumblr.com/db3b68e5ccc2ebe25094b1e4c92aa0e2/tumblr_n18bh30XJk1qh588ko1_500.gif',
      ];
      //iterate png number to match up with image
      var imageArray = [];
      for (var i = 0; i < png.length; i++) {
        for (var j = 0; j < bodyImages.length; j++) {
          if (png[i] == iconNum) {
            imageArray.push(bodyImages[j]);
            $('body').css('background-image', 'url(' + imageArray[i] + ')');
          }
        }
      }
      //convert temp and wind
      var mph = (wind * 1.609344).toFixed(1);
      var temp2 = ((temperature - 32) * 5 / 9).toFixed(0);
      $("button").click(function() {
        if ($('.btn').is(":contains('\xB0 F')")) {
          $('.btn').html(temp2 + '\xB0 C');
          $('.wind').html('Wind:<br>' + mph + ' kph')
        } else {
          $('.btn').html(temperature + '\xB0 F');
          $('.wind').html('Wind:<br>' + wind + ' mph');
        }
      });
    }, 'jsonp')
  }
}); 

//credits: modified based on scripts by Michael Morris 2016
            
          
!
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