Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

HTML

              
                <div id="container">
            
		
           <div class="col-md-6 col-md-offset-3">
		   <div id="header" class="text-center">
                <h1>Local weather</h1>
            </div>    
			<div class="row">	
      <div class="panel panel-primary">
        <div class="panel-heading"><br/><section class="text-center" id="datetime"></section>
  </div>
        <div class="panel-body">
		<div class="col-sm-4 well-lg">
  <div id="wmain"></div>
	<div class="text-center all-icon">	
          <div class="icon sun-shower hide ">
            <div class="cloud"></div>
            <div class="sun">
              <div class="rays"></div>
            </div>
            <div class="rain"></div>
          </div>
        <div class="icon thunder-storm hide thunderstom">
            <div class="cloud"></div>
            <div class="lightning">
              <div class="bolt"></div>
              <div class="bolt"></div>
            </div>
          </div>
          <div class="icon cloudy hide clouds">
            <div class="cloud"></div>
            <div class="cloud"></div>
          </div>
          <div class="icon flurries hide snow">
            <div class="cloud"></div>
            <div class="snow">
              <div class="flake"></div>
              <div class="flake"></div>
            </div>
          </div>
          <div class="icon sunny hide clear">
            <div class="sun">
              <div class="rays"></div>
            </div>
          </div>
          <div class="icon rainy hide rain">
            <div class="cloud"></div>
            <div class="rain"></div>
          </div>
		</div>
  </div>
            <div class="col-sm-4 well-lg"> 
  <section class="">
  <p class="text-left"><span id="city"><strong>...</strong></span>, <span id="country"><strong>...</strong></span></br>
	Condition : <span id="weatherData"></span></br>
	Wind : <span id="windSpeed"></span></p> 
<section>	
  </div>
			<div class="col-sm-4 well-lg text-center">  
  <span id="temperature">...</span>  
  <section class="well-sm">
	<!--<label class="toggle candy blue units-toggle">	
	<input id="units_check" type="checkbox" checked="checked"/>
	<p>
	<span>  °F   </span>
	<span>  °C	 </span>
	</p> 
	<a class="slide-button well"></a>	
	</label>-->
</section>	
  </div>
		</div>
        </div>
			</div>
			</div>
			 
		</div>

              
            
!

CSS

              
                /** Tutorial - Bootstrap font-size: 1.2em;**/

html, body {
    height: 100%;
    margin: 0;
	padding: 0;
	font-family: Arial, sans-serif;				
	color:#fff;
	background: url("http://www.on-foto.co.uk/imagery/uk-weather-winter.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

/** Defaults **/

#header {
    height: 50px;
	color:#fff;	
}

#content {
    background: rgb(230, 230, 230);
    float: left;  	
	padding-right: auto; padding-left: auto;
    width: 100%;
}
#temperature{
  cursor:pointer;
  color:#fff;
}
#temperature:hover{
  color:#fff;
}
.col-sm-4 {margin-top:10px; } 
.col-md-6{ 
	padding:20px; 
	margin-top: 10%;
	box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
	border-radius: 6px;
	background-color: rgba(255,255,255,0.5)!important; 
	color:#fff;	
	
}
 .panel {
        background: none;
    }
.panel.panel-heading{
	height:90px;	
	
}
.panel-heading{
        background: rgba(122, 130, 136, 0.2)!important;
		border: none;
		font-size: 1.4em;						
    }
.panel,.panel-body{
        background-color:rgba(11, 136, 168, 0.8)!important;
		color:#fff;
	}
.panel,.panel-primary{	
	margin-top: 10px;
	margin-right: auto; margin-left: auto;	
	width: 90%;
	border:none;
}
.well {
		float: left;
        background: none;
		border: none;
		padding-left:10%;
}
.well-lg{

	top:0%;     
    left:0%; padding-right:0%;
	width: 25%;	
	margin-right: 0; margin-left: 5%;	
}
.well-sm{
	position: relative;
	top:0%;
	left:-80%; right:0%;
} 

#footer {
    clear: both;
    text-align: center;
	color:#fff;	
	font-size: 10px;
	margin-bottom: 3%;
}

#header, #footer {
    border: none;
    
}

/** Media Queries to handle particular cases padding: 5px 15px;**/

/* 980px or less */
@media screen and (max-width: 980px) {
    #content {
        width: 60%;
    }
    .well-lg {
        width: 30%;
    }
	.panel, .panel-primary{		
		width: 15%;    
	}
	.well-sm{	
		float: left;		
		top:0%;
		left:120%; right:0%;
	} 
}

/* 700px or less */
@media screen and (max-width: 700px) {
    #content {
        width: 80%;
        float: none;
    }
    .well-lg {
        width: 60%;
        float: none;
    }
	.panel, .panel-primary{
		margin: none;
		width: 30%;    
	}
	.well-sm{	
		float: none;		
		top:0%;
		left:-60%; right:0%;
	} 
}

/* 480px or less */
@media screen and (max-width: 480px) {
    #header {
        height: auto;
    }
    h1, h2 {
        font-size: 22px;
    }
	#content {
        width: 100%;
    }
    .well-lg{
        width: 90%;
        float: none;
		margin:none;
    }
	.panel, .panel-primary{
		margin: none;
		width: 80%; 
		font-size: 12px;
	}
	.panel-heading{
		text-align:center;
		padding-top:none;
		margin: none;
	}
	.well-sm{
		float: left;		
		top:0%;
		left:-90%; right:0%;
	} 
}
 
 
.all-icon {
  margin-bottom: 20px;
}

div.hide {
  display: none;
}

.icon {
  color: #fff;
  position: relative;
  display: inline-block;
  width: 12rem;
  height: 10rem;
   margin-top: -15px;
}

.cloud {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 3.6875em;
  height: 3.6875em;
  margin: -1.84375em;
  background: currentColor /*#fff*/;
  border-radius: 50%;
  box-shadow:
    -2.1875em 0.6875em 0 -0.6875em,
    2.0625em 0.9375em 0 -0.9375em,
    0 0 0 0.375em #fff,
    -2.1875em 0.6875em 0 -0.3125em #fff,
    2.0625em 0.9375em 0 -0.5625em #fff;
}
.cloud:after {
  content: '\f105';
  position: absolute;
  bottom: 0;
  left: -0.5em;
  display: block;
  width: 4.5625em;
  height: 1em;
  background: currentColor /*#fff*/;
  box-shadow: 0 0.4375em 0 -0.0625em #fff;
}
.cloud:nth-child(2) {
  z-index: 0;
  background: #fff;
  box-shadow:
    -2.1875em 0.6875em 0 -0.6875em #fff,
    2.0625em 0.9375em 0 -0.9375em #fff,
    0 0 0 0.375em #fff,
    -2.1875em 0.6875em 0 -0.3125em #fff,
    2.0625em 0.9375em 0 -0.5625em #fff;
  opacity: 0.3;
  transform: scale(0.5) translate(6em, -3em);
  animation: cloud 4s linear infinite;
}
.cloud:nth-child(2):after { background: #fff; }

.sun {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.5rem;
  height: 2.5rem;
  margin: -1.25rem;
  background: #fcd213;/*background: currentColor;*/
  border-radius: 50%;
  box-shadow: 0 0 0 0.375rem #fff;
  box-shadow: inset 0 -4px 8px rgba(255,190,0,1), 0 0 8px #fccc0e;
    -webkit-box-shadow :inset 0 -4px 8px rgba(255,190,0,1), 0 0 8px #fccc0e;
    -moz-box-shadow: inset 0 -4px 8px rgba(255,190,0,1), 0 0 8px #fccc0e;
  -webkit-animation: spin 12s infinite linear;
  animation: spin 12s infinite linear;
}

.rays {
  position: absolute;
  top: -2em;
  left: 50%;
  display: block;
  width: 0.375em;
  height: 1.125em;
  margin-left: -0.1875em;
  background: #fcd213;
  border-radius: 0.25em;
  box-shadow: 0 5.375em #fcd213;
}
.rays:before,
.rays:after {
  content: '';
  position: absolute;
  top: 0em;
  left: 0em;
  display: block;
  width: 0.375em;
  height: 1.125em;
  transform: rotate(60deg);
  transform-origin: 50% 3.25em;
  background: #fcd213;
  border-radius: 0.25em;
  box-shadow: 0 5.375em #fcd213;
}
.rays:before {
  transform: rotate(120deg);
}
.cloud + .sun {
  margin: -2em 1em;
}

.rain,
.lightning,
.snow {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 3.75em;
  height: 3.75em;
  margin: 0.375em 0 0 -2em;
  background: currentColor;
}

.rain:after {
  content: '';
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 1.125em;
  height: 1.125em;
  margin: -1em 0 0 -0.25em;
  background: #0cf;
  border-radius: 100% 0 60% 50% / 60% 0 100% 50%;
  box-shadow:
    0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
    -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
    -1.375em -0.125em 0 rgba(255,255,255,0.2);
  transform: rotate(-28deg);
  animation: rain 3s linear infinite;
}

.bolt {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -0.25em 0 0 -0.125em;
  color: #fff;
  opacity: 0.3;
  animation: lightning 2s linear infinite;
}
.bolt:nth-child(2) {
  width: 0.5em;
  height: 0.25em;
  margin: -1.75em 0 0 -1.875em;
  transform: translate(2.5em, 2.25em);
  opacity: 0.2;
  animation: lightning 1.5s linear infinite;
}
.bolt:before,
.bolt:after {
  content: '';
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  margin: -1.625em 0 0 -1.0125em;
  border-top: 1.25em solid transparent;
  border-right: 0.75em solid;
  border-bottom: 0.75em solid;
  border-left: 0.5em solid transparent;
  transform: skewX(-10deg);
}
.bolt:after {
  margin: -0.25em 0 0 -0.25em;
  border-top: 0.75em solid;
  border-right: 0.5em solid transparent;
  border-bottom: 1.25em solid transparent;
  border-left: 0.75em solid;
  transform: skewX(-10deg);
}
.bolt:nth-child(2):before {
  margin: -0.75em 0 0 -0.5em;
  border-top: 0.625em solid transparent;
  border-right: 0.375em solid;
  border-bottom: 0.375em solid;
  border-left: 0.25em solid transparent;
}
.bolt:nth-child(2):after {
  margin: -0.125em 0 0 -0.125em;
  border-top: 0.375em solid;
  border-right: 0.25em solid transparent;
  border-bottom: 0.625em solid transparent;
  border-left: 0.375em solid;
}

.flake:before,
.flake:after {
  content: '\2744';
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -1.025em 0 0 -1.0125em;
  color: #fff;
  list-height: 1em;
  opacity: 0.2;
  animation: spin 8s linear infinite reverse;
}
.flake:after {
  margin: 0.125em 0 0 -1em;
  font-size: 1.5em;
  opacity: 0.4;
  animation: spin 14s linear infinite;
}
.flake:nth-child(2):before {
  margin: -0.5em 0 0 0.25em;
  font-size: 1.25em;
  opacity: 0.2;
  animation: spin 10s linear infinite;
}
.flake:nth-child(2):after {
  margin: 0.375em 0 0 0.125em;
  font-size: 2em;
  opacity: 0.4;
  animation: spin 16s linear infinite reverse;
}


/* Animations */ 

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@keyframes cloud {
  0% { opacity: 0; }
  50% { opacity: 0.3; }
  100% {
    opacity: 0;
    transform: scale(0.5) translate(-200%, -3em);
  }
}

@keyframes rain {
  0% {
    background: #0cf;
    box-shadow:
      0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
      -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
      -1.375em -0.125em 0 #0cf;
  }
  25% {
    box-shadow:
      0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
      -0.875em 1.125em 0 -0.125em #0cf,
      -1.375em -0.125em 0 rgba(255,255,255,0.2);
  }
  50% {
    background: rgba(255,255,255,0.3);
    box-shadow:
      0.625em 0.875em 0 -0.125em #0cf,
      -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
      -1.375em -0.125em 0 rgba(255,255,255,0.2);
  }
  100% {
    box-shadow:
      0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2),
      -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2),
      -1.375em -0.125em 0 #0cf;
  }
}

@keyframes lightning {
  45% {
    color: #fff;
    background: #fff;
    opacity: 0.2;
  }
  50% {
    color: #0cf;
    background: #0cf;
    opacity: 1;
  }
  55% {
    color: #fff;
    background: #fff;
    opacity: 0.2;
  }
}
              
            
!

JS

              
                var key= config.MY_KEY;
var cel = false;
var wdata;
var temperature;
var celsius = " °C";
var fah = " °F";

function roundTemp(temperature){
			temperature = +temperature.toFixed(0);
			return temperature;
		}
/*
	°F = °C  x  9/5 + 32 
	°C = (°F  -  32)  x  5/9
*/
function flipUnits(f,c){
	if(c) return roundTemp((f- 32) * (5/9)) + celsius;
	return roundTemp(f) + fah;
}

function weathericons(city) {	
	var city = city.toLowerCase();
    if (city == 'dizzle') {
		addWeatherIcon(city);	
	}else if (city == 'clouds'){
		addWeatherIcon(city);	
	}else if (city == 'rain'){
		addWeatherIcon(city);	
	}else if (city == 'snow'){
		addWeatherIcon(city);	
	}else if (city == 'clear'){
		addWeatherIcon(city);	
	}else if(city == 'thunderstom'){
		addWeatherIcon(city);	
	}else {
		$('div.clouds').removeClass('hide');	
	}
}
  
  function addWeatherIcon(city) {
    $('div.' + city).removeClass('hide');
  }

function currentWeather(wdata, cel){

var weatherData = wdata.weather[0].description;
var wmain = weathericons(wdata.weather[0].main);
temperature = flipUnits(wdata.main.temp, cel);
var windSpeed = (wdata.wind.speed).toFixed(0);		
var city = wdata.name;
var country = wdata.sys.country;
var icon = wdata.weather[0].icon;
				
$("#city").html(city);
$("#country").html(country);
$("#weatherData").html(weatherData);
$("#temperature").html(temperature);
$("#windSpeed").html(windSpeed + " mph");
$("#wmain").append(wmain);
}

$(document).ready(function(){   
				
			$.getJSON('http://ip-api.com/json',function(data){
				var lat=data.lat;
				var log= data.lon;			
			
			$.getJSON('http://api.openweathermap.org/data/2.5/weather?units=imperial&lat='+lat+'&lon='+log+'&appid='+key, function(apiData){
			
			wdata = apiData;
			currentWeather(apiData, cel);
			
			$("#temperature").click(function(){
			cel = !cel;
			currentWeather(wdata, cel);
			});
			
		});
	}); 
});
function datetime(){
        date = new Date;
        year = date.getFullYear();
        month = date.getMonth();
        months = new Array(['January'], ['February'], ['March'], ['April'], ['May'], ['June'], ['Jully'], ['August'], ['September'], ['October'], ['November'], ['December']);
        d = date.getDate();
        day = date.getDay();
        days = new Array(['Sunday'], ['Monday'], ['Tuesday'], ['Wednesday'], ['Thursday'], ['Friday'], ['Saturday']);
        h = date.getHours();
        if(h<10)
        {
                h = "0"+h;
        }
        m = date.getMinutes();
        if(m<10)
        {
                m = "0"+m;
        }       
       var result = ''+days[day]+' '+d+' '+months[month]+' '+year+' '+h+':'+m;
       document.getElementById('datetime').innerHTML = result;		
}
window.onload=function(){
datetime();
setTimeout(datetime,1000);
}
              
            
!
999px

Console