cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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.

            
              <head>
  <link href='https://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script src="/js/plugins/openWeather.js"></script>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="title"><h1>Free C<span class="icon"><img src="http://www.richardkeightley.com/Images/cloud_icon.png" width=80px></span>de Camp<br>Weather App</h1>
      </div> <!-- end of title div -->
    </div> <!-- end of row div -->
<form id="myForm" method="post" autocomplete="off">
<div class="row white">
  <span class="col-md-1"></span><span class="col-md-10">
  Zip code: 
  <input type="text" id="zip" class="black"/>
  <input type="button" onclick="show()" value="Show it" class="black"/>
  <input type="button" onclick="reset()" value="Reset form" class="black"/>
  </span><span class="col-md-1"></span>
    </div></form>

<div class="row white" id="info">
  <span class="col-md-1"></span> <!-- left margin -->
  <span class="col-md-10">
    <div>Location: <span id="location"></span></div>
    <div>Conditions: <span id="description"></spa></div>
    <div>Temperature: <span><a href="#" id="temperature" onclick="changeTemp()"></a></span></div>
    <span class="col-md-1"></span> <!-- right margin -->
</div> <!-- end row -->

    
<div class="symbol sun-shower" id="partly">
  <div class="cloud"></div>
  <div class="sun">
    <div class="rays"></div>
  </div>
</div>
  
<div class="symbol cloudy" id="clouds">
  <div class="cloud"></div>
  <div class="cloud"></div>
</div>
  
<div class="symbol flurries" id="snow">
  <div class="cloud"></div>
  <div class="snow">
    <div class="flake"></div>
    <div class="flake"></div>
  </div>
</div>
  
<div class="symbol rainy" id="rain">
  <div class="cloud"></div>
  <div class="rain"></div>
</div>
  
<div class="symbol sunny" id="sun">
  <div class="sun">
    <div class="rays"></div>
  </div>
</div>
  
<div class="symbol thunder-storm" id="storm">
  <div class="cloud"></div>
  <div class="lightning">
    <div class="bolt"></div>
    <div class="bolt"></div>
  </div>
</div>

</body>
            
          
!
            
              html { box-sizing: border-box; }
html *,
html *:before,
html *:after { box-sizing: inherit; }

body { 
  width: 100%; height: 100%;
  background-color: currentColor;
  color: #161616;  
  font-family: 'Roboto', sans-serif;
}

.container {
  position: absolute;
  left: 50%;
  top: 5%;
  transform: translate(-50%) ;
}
h1 {
  font-size: 60px;
}
a {
  color: white;
  text-decoration: none;
  padding: 0 4px 0 4px;
  border-radius: 4px;
}
a:hover {
  color: white;
  font-size: 30px;  
  text-decoration: none;
}
a:link{
  color:white;
}
a:visited{
  color:white;
  text-decoration: none;
}

.white {
  color: white;
}

.black {
  text-align: center;
  color: black;
  background: lightgray;
}

.black:hover {
  transition: background .2s ease;
  background: white;
}

#zip {
  width: 200px;
}

.title {
  font-size: 60px;
  text-align: center;
  color: white;
}

.row {
  font-size: 30px;
  text-align: left;
}

.icon {
  position: relative;
  top: -10px;  
}

.symbol {
  position: relative;
  display: inline-block;
  width: 18em;
  height: 1em;
  font-size: 1em; /* control icon size here */
}
.cloud {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 3.6875em;
  height: 3.6875em;
  margin: -1.84375em;
  background: currentColor;
  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: '';
  position: absolute;
  bottom: 0;
  left: -0.5em;
  display: block;
  width: 4.5625em;
  height: 1em;
  background: currentColor;
  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.5em;
  height: 2.5em;
  margin: -1.25em;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 0.375em #fff;
  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: #fff;
  border-radius: 0.25em;
  box-shadow: 0 5.375em #fff;
}
.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: #fff;
  border-radius: 0.25em;
  box-shadow: 0 5.375em #fff;
}
.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;
  }
}

#snow, #rain, #clouds, #storm, #sun, #partly {
  position: relative;
  top: -80px;
}

#rain {
  right: 258px;
}

#clouds {
  left: 255px;
}

#storm {
  left: 255px;
  top: -100px;
}

#partly, #sun {
  left: 510px;
}
            
          
!
            
              // global variables
var farActive = 1;
var far = 0;
var cel = 0;
var id=0;

$( document ).ready(function() {
document.getElementById("sun").style.visibility= "hidden";
document.getElementById("storm").style.visibility= "hidden";
document.getElementById("clouds").style.visibility= "hidden";
document.getElementById("rain").style.visibility= "hidden";
document.getElementById("partly").style.visibility= "hidden";
document.getElementById("snow").style.visibility= "hidden"; 
});

function show(){
// hide all animated weather icons
document.getElementById("storm").style.visibility= "hidden";
document.getElementById("clouds").style.visibility= "hidden";
document.getElementById("rain").style.visibility= "hidden";
document.getElementById("partly").style.visibility= "hidden";
document.getElementById("snow").style.visibility= "hidden"; 
document.getElementById("sun").style.visibility= "hidden";
  
var zipCode = document.getElementById("zip").value;

// weather information from openweatherAPI
var apiKey = ',us&appiD=8a3546f257b155d6f8babbf970983689';
var url = 'http://api.openweathermap.org/data/2.5/weather?zip=';

var request = new XMLHttpRequest();
 request.open("GET", url+zipCode+apiKey, false);
 request.send();
 request = JSON.parse(request.responseText);
var description = request.weather[0].description;
id = request.weather[0].id;
  console.log(id);
var kel = request.main.temp;
cel = (kel - 273.15).toFixed(0);
far = (kel * 1.8 - 459.67).toFixed(0);

farActive = 1;
  
// geolocation information from ziptastic
  var zipCode = document.getElementById("zip").value;
  var zurl = 'http://ziptasticapi.com/';
  var request2 = new XMLHttpRequest();
  request2.open("GET", zurl+zipCode, false);
  request2.send();
  request2 = JSON.parse(request2.responseText);
  var state = request2.state;
  var city = request2.city;  
  description = request.weather[0].description;
  
// display info
document.getElementById('description').textContent=description;
document.getElementById("temperature").textContent = far + "° F"; 
document.getElementById("location").textContent = city + ", " + state;

  // show weather icon
  if (id>=200 && id<300) {
    // show thunderstorm
    document.getElementById("storm").style.visibility= "visible";
  }
  if (id>=300 && id<600) {
    // show rain
    document.getElementById("rain").style.visibility= "visible";
  }
  if (id>=600 && id<700) {
    // show snow
    document.getElementById("snow").style.visibility= "visible"; 
   }
  if (id==800) {
    // show sun
    document.getElementById("sun").style.visibility= "visible";
  }
  if (id>800 && id<=803) {
    // show partly clouds
    document.getElementById("partly").style.visibility= "visible"; 
  }
  if (id==804){
    // show clouds
    document.getElementById("clouds").style.visibility= "visible";
  }
}

function reset(){
	document.getElementById("myForm").reset();
}

function changeTemp()
{
  console.log(farActive);
  if (farActive ==1) 
  {
    cel = (far -32) * (5/9);
    far = 0;
    document.getElementById('temperature').textContent=cel.toFixed(0)+'° C';
    farActive = 0;
  }
  else 
  {
    far = cel * 1.8+32;
    cel = 0;
    document.getElementById('temperature').textContent=far.toFixed(0)+'° F';
    farActive = 1;
  }
}
            
          
!
999px
Loading ..................

Console