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.

            
              <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="container">

  <div class="weather">
    <div id="icon">
      </i>
    </div>
    <span id="desc">what's</span>
    <span id="temp">the</span>
    <span id="wind">weather?</span>
  </div>
  <div class="searchbox">
    <input type="text" name="search" placeholder="Enter town/city and country" id="search">
    <br>
    <button id="sbutton">Search</button>
    <button id="lbutton">Share Location</button>
  </div>
  <div id="location">
    <div>
    </div>
            
          
!
            
              body {
  background-color: #42a5f5;
  font-family: 'Open Sans';
}

.container {
  width: 80%;
  margin: 10% auto;
}

button {
  font-family: 'Open Sans';
  border: 0px;
  margin: 20px 6px;
  background-color: #1565c0;
  color: white;
  padding: 6px;
  border-radius: 3px;
  cursor: pointer;
}

input {
  height: 30px;
  border: 2px solid #1565c0;
  text-align: center;
  width: 300px;
}

.weather {
  padding:10px;
  text-align: center;
  margin:10px;
}

#desc {
  color: white;
  font-size: 2.4rem;
  padding: 0px 4px;
  font-weight:bold;
}

.searchbox {
  text-align: center;
}

#temp {
  color: white;
  font-size: 2rem;
  padding: 0px 4px;
}

.owf {
  color: white;
  font-size:10rem;
}

#wind {
  font-size: 2rem;
  padding: 0px 4px;
  color: white;
}

#location {
  text-align: right;
  width: 400px;
  color: #0d47a1;
  margin: 0 auto;
  font-size: 1.1rem;
}

button:active {
  background-color: #0d47a1;
}

input:focus{
  border:2px solid #283593;
}
            
          
!
            
              var uInput;

function result(){
  $.getJSON(
    "https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?" + uInput + "&APPID=c0d43ee7e2aa2b4857d026c60d25a5a1",
    function(data) {

      var w = data.weather[0].description;
      var t = data.main.temp - 273.15;
      var city = data.name;
      var vCountry = data.sys.country;
      var vWind = data.wind.speed * 2.236936;
      var vIcon = data.weather[0].id;
      var nd = data.weather[0].icon.substring(2);

      t = Math.ceil(t);
      vWind = Math.ceil(vWind) + "mph wind";

      $('#desc').html(w);
      $('#temp').html(t + "&#8451");
      $('#wind').html(vWind);
      $('#location').html(city + " " + vCountry);
      $('#icon').html("<i class='owf owf-" + vIcon + "-" + nd + "'>");
    });
}

//Gets location from search and outputs result
$('#sbutton').on('click', function() {
  uInput =  "q=" + $("#search").val();
   result();
});
//Gets location from search and outputs result
$('.searchbox').keypress(function(e){
    if (e.which === 13){
        $('#sbutton').click();}
});

//Gets geolocation
$('#lbutton').on('click', function(){
  
  navigator.geolocation.getCurrentPosition(getLocation);
  
  function getLocation(position){
    lat = position.coords.latitude;
    lon = position.coords.longitude;
    uInput = "lat=" + lat + "&" + "lon=" + lon;
    
    result();
  }
  
});
            
          
!
999px
Loading ..................

Console