Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

HTML

              
                <div class="se-pre-con"></div>
<div class="container container-fluid ">

  <!-- Testing: uncomment following dropdown menu:
		<select id="cities">
				<option>Dubai</option>
				<option>London</option>
				<option>Antarctica</option>
				<option>New Mexico</option>
				<option>Helsinki</option>
				<option>Howey-in-the-Hills, FL</option>
				<option>Akyab</option>
				<option>Kolkata</option>
				<option>Karachi</option>
				<option>Melbourne</option>
				<option>Alice Springs</option>
				<option>New Jersey</option>
				<option>Cape Town</option>
				<option>Berlin</option>
				<option>Vladivostock</option>
				<option>Sofia</option>
				<option>Llanfairpwllgwyngyll</option>
				<option>Madrid</option>
				<option>Llanberis</option>
				<option>Greenland</options>
				<option>Vermont</option>
		</select> -->
  <div class="jumbotron">
    <span class="location"></span>
    <span class="country"></span>
    <div class="temp-container">
      <div class="testcell">
        <table class="degrees-tbl">
          <tr>
            <td rowspan="2" class="temperature"></td>
            <td colspan="2" class="degrees-text">DEGREES</td>
          </tr>
          <tr>
            <td class="celsius-box">C</td>
            <td class="fahrenheit-box">F</td>
          </tr>
        </table>
      </div>
      <div class="testcell">
<!--         <span class="climate_bg"></span> -->
      </div>
      <div class="testcell">
        <table class="currently-text-tbl">
          <tr>
            <td class="currently"></td>
          </tr>
          <!-- 							<tr>
								<td class="text"></td>
							</tr> -->
        </table>
      </div>
    </div>

  </div>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Dancing+Script);
@import url(https://fonts.googleapis.com/css?family=Lato);

.no-js #loader {
  display: none;
}

.js #loader {
  display: block;
  position: absolute;
  left: 100px;
  top: 0;
}

.se-pre-con {
  position: fixed;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: url("http://smallenvelop.com/wp-content/uploads/2014/08/Preloader_21.gif") center no-repeat #fff;
}

body {
  width: 100%;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  font-family: 'Dancing Script', cursive;
  font-size: 3em;
  color: #ffffff;
  text-rendering: optimizeLegibility;
  margin-top: 20px;
}

p {
  display: inline-block;
}

.jumbotron {
  position: relative;
  background-color: transparent;
  border-radius: 20px !important;
  background: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.5));
  border: 1px solid gray;
}

.jumbotron .location {
  font-size: 5em;
  display: block;
  text-align: center;
  overflow: visible;
}

.jumbotron .country {
  font-size: 1.0em;
  display: block;
  text-align: center;
}

.jumbotron .temp-container {
  display: block;
  display: table;
  width: 100%;
  height: 100%;
}

.jumbotron .temp-container .testcell {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  line-height: 1em;
  width: 33%;
  position: relative;
}

.jumbotron .temp-container .testcell .degrees-tbl {
  font-family: 'Lato', sans-serif;
  margin-left: auto;
  margin-right: auto;
  height: 2.5em;
  padding: 0;
  display: table;
  height: 45px;
}

.jumbotron .temp-container .testcell .degrees-tbl .temperature {
  display: table-cell;
  height: 5px;
  font-size: 1.8em;
  width: 110px;
  text-align: right;
}

.jumbotron .temp-container .testcell .degrees-tbl .degrees-text {
  display: table-cell;
  line-height: 5px;
  font-size: 0.4em;
  bottom: 0;
  padding: 0;
}

.jumbotron .temp-container .testcell .degrees-tbl .celsius-box, .jumbotron .temp-container .testcell .degrees-tbl .fahrenheit-box {
  display: table-cell;
  line-height: 18px;
  text-align: left;
  font-size: 1.1em;
  color: gray;
  user-select: none;
  -webkit-transition: all 0.2s ease-in-out;
  -moz-transition: all 0.2s ease-in-out;
  -o-transition: all 0.2s ease-in-out;
  -ms-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
}

.jumbotron .temp-container .testcell .degrees-tbl .celsius-box:hover, .jumbotron .temp-container .testcell .degrees-tbl .celsius-box.hover, .jumbotron .temp-container .testcell .degrees-tbl .fahrenheit-box:hover, .jumbotron .temp-container .testcell .degrees-tbl .fahrenheit-box.hover {
  color: #D9DDDB !important;
  cursor: pointer;
}

.jumbotron .temp-container .testcell .climate_bg {
  -webkit-filter: invert(100%);
}

.jumbotron .temp-container .testcell .currently-text-tbl {
  margin-left: auto;
  margin-right: auto;
}

.jumbotron .temp-container .testcell .currently-text-tbl .currently {
  font-size: 1.6em;
  height: 1.0em;
}

.jumbotron .temp-container .testcell .currently-text-tbl .text {
  font-size: 0.6em;
}

/* Portrait tablet to landscape and desktop */
/* Landscape phone to portrait tablet */
/* Landscape phones and down */
@media (max-width: 480px) {
  body {
    width: 100%;
    height: 100%;
  }
  .jumbotron .location {
    font-size: 2em;
    display: block;
    text-align: center;
    overflow: hidden;
  }
  .jumbotron .temp-container {
    font-size: 80%;
  }
  .temperature {
    width: 50px !important;
  }
}

@media (min-width: 450px) and (max-width: 500px) {
  body {
    height: 100%;
  }
  .jumbotron .location {
    line-height: 80px;
  }
}
              
            
!

JS

              
                "use strict";

jQuery(document).ready(function($) {
	// Testing: use following line---------------
	// setInterval(loadWeather, 2000);
	$.getJSON('http://ip-api.com/json/?callback=?').done(function(data){
		loadWeather(data.city + ', ' + data.country, '', '');
	});
});

function loadWeather(location, woeid, unit){
	$.simpleWeather({
		// Testing: use following 2 lines---------------
		// location: $('#cities').val(),
		// woeid: '',
		location: location,
		woeid: woeid,
		unit: 'c',
		success: function(weather){
			console.log(weather);
			console.log(weather.code);

			// Handle location font size
			if( this.location.length > 19 ){
				$('.location').css('font-size', '3.0em');
			}

			else if( this.location.length > 11 ){
				$('.location').css('font-size', '3.5em');
			}

			else if( this.location.length > 9 ){
				$('.location').css('font-size', '4.0em');
			}

			else if( this.location.length > 7 ){
				$('.location').css('font-size', '4.5em');
			}

			// Handle location font size on phone screens
			if (Modernizr.mq('(max-width: 480px)')) {
				if( this.location.length < 11){
				    $('.location').css('font-size', '2em');
				}
				else if( this.location.length >= 11 && this.location.length < 18){
				    $('.location').css('font-size', '2.0em');
				}
				else if( this.location.length >= 18 ){
				    $('.location').css('font-size', '1.0em');
				}
			}

			// Assign object vars to shortened names
			var city = weather.city;
			var temp = weather.temp;
			var wcode = '<img class="weathericon" src="images/weathericons/' + weather.code + '.svg">';
			var wind = '<p>' + weather.wind.speed + '</p><p>' + weather.units.speed + '</p>';
			var humidity = weather.humidity + '%';
			var currently = weather.currently;
			var text = '';
			var country = weather.country;
			if(currently !== weather.text){
				text = weather.text;
			}

			// Handle current weather font size
			if(currently.length >= 1 && currently.length <= 4){
				$('.currently').css('font-size', '1.6em');
			}
			else if(currently.length >= 5 && currently.length <= 9){
				$('.currently').css('font-size', '90%');
			}
			else if(currently.length >= 10 && currently.length <= 15){
				$('.currently').css('font-size', '80%');
			}
			else if(currently.length >= 15 && currently.length <= 22){
				$('.currently').css('font-size', '70%');
			}

			// Assign shortened variables to DOM classes
			$('.code').text('CODE: ' + weather.code);
			$('.location').text(city);
			$('.temperature').html(temp);
			$('.climate_bg').html(wcode);
			$('.windspeed').html(wind);
			$('.humidity').text(humidity);
			$('.currently').text(currently);
			$('.text').text(text);
			$('.country').text(country)

			// Assign background image links to variables
			var sunnyImg 	= "http://u.kanobu.ru/comments/images/92025b04-c980-46da-8859-66f64c997468.jpg";
			var rainyImg 	= "http://webneel.com/wallpaper/sites/default/files/images/04-2013/cute-rain-in-mirror.jpg";
			var cloudyImg 	= "http://p1.pichost.me/i/31/1542826.jpg";
			var snowyImg 	= "https://wallpaperscraft.com/image/snow_white_background_surface_79574_2560x1440.jpg";
			var clearImg_n 	= "http://images.summitpost.org/original/472297.jpg";
			var cloudyImg_n = "https://c1.staticflickr.com/1/92/211605391_782caa152f_b.jpg";

			function changeBgImg(linkToImg) {
				return $('body').css('background-image', 'url(' + linkToImg + ')');
			}
			// Set background images
			var c = parseInt(weather.code);
			switch(true) {
				// Rainy
				case (c >= 0 && c <= 12 || c === 35 || c >= 37 && c <= 40 || c >= 45 && c <= 47):
					changeBgImg(rainyImg);
					break;
				// Sunny
				case (c === 19 || c === 21 || c === 22 || c === 32 || c === 34 || c === 36):
					changeBgImg(sunnyImg);
					break;
				// Cloudy
				case (c === 20 || c >= 23 && c <= 26 || c === 28 || c === 30):
					changeBgImg(cloudyImg);
					break;
				// Snow

				case (c >= 13 && c <= 18 || c === 41 || c === 42 || c === 46):
					changeBgImg(snowyImg);
					break;
				// Cloudy (night)
				case (c === 27 || c === 29):
					changeBgImg(cloudyImg_n);
					break;
				// Clear (night)
				case (c === 31 || c === 33):
					changeBgImg(clearImg_n);
					break;
				default:
					changeBgImg('http://www.imgbase.info/images/safe-wallpapers/animals/cat/37493_cat_kitten_orange_kitten.jpg');
					break;
			};

			// Greying or whiting C and F
			var activeCelsius = function(){
				$('.temperature').html(temp);
				$('.celsius-box').css('color', 'white');
				$('.fahrenheit-box').css('color', 'gray');
			};

			activeCelsius();

			$('.celsius-box').on('click', function() {
				activeCelsius();
			});

			var celsToFahr = Math.round(((parseInt(temp) * 9) / 5) + 32);

			$('.fahrenheit-box').on('click', function() {
				$('.temperature').html(celsToFahr);
				$('.fahrenheit-box').css('color', 'white');
				$('.celsius-box').css('color', 'gray')
			});
			// Once it's all loaded, fade out the loading screen
			$(".se-pre-con").fadeOut("slow");
		},

		error: function(error){
			$('.error').html('<p>' + error + '</p>');
		}
	});
}
              
            
!
999px

Console