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.

            
              <div class="container text-center margin">


  <div id="cityInput" class="margin-auto">
    <input type="text" placeholder="Enter a city name" name="cityname" id="cityName" class="margin">
    <button type="submit" value="Submit" id="search" class="margin margin-auto padding-top-bottom">Check The Weather</button>
  </div>

  <div id="appContainer" class="margin-auto disabled">
    <div id="locationConainter">
      <h1 id="locationName"></h1>
      <p id="countryName"></p>
      <p id="locationCoordinates"></p>
    </div>

    <div id="weatherContainer" class="margin-auto">
      <img id="weatherIcon" class="padding-small" alt="" src="" />

      <h3 class="padding-small">
      
        <span id="temp"></span>
        <span id="tempUnit"></span>
       
      </h3>

      <h3 id="sky" class="padding-small"></h3>

    </div>

    <button type="submit" value="Submit" id="units" class="disabled">Imperial / &#8457</button>

    <button type="submit" value="Submit" id="units2" class="disabled">Metric / &#8451 </button>

  </div>

  <button type="submit" value="Submit" id="reload" class="margin disabled">Try another search</button>

</div>
            
          
!
            
              body{
  background: #6DAFE5; 
  
}

.margin {
  margin-top:50px;
  margin-bottom:50px;
}

.margin-auto {
  margin-left: auto;
  margin-right: auto;
}

.padding-small {
  padding: 20px;
}

.padding-top-bottom{
  padding-top: 10px;
  padding-bottom: 10px;
}


.disabled {
  display: none;
}

.opacityNone {
  opacity:0; 
}

#cityInput {
  max-width: 700px;
  -webkit-transition: all .3s linear 0s;
  transition: all .3s linear 0s;
  
}

#cityName, button {
  border-radius: 5px;
  border: none;
  text-align: center; 
}

#cityName {
  font-size: 40px;
  width: 100%;
}

#appContainer {
  background: #CCE6FB;
  border-radius: 5px;
  -webkit-transition: all .3s linear 0s;
  transition: all .3s linear 0s;
}

#appContainer, #weatherContainer {
  color: #2A7BBE;
  max-width: 500px;
  height:auto;
  padding: 50px 0;
}

 #weatherContainer {
   border-top: 1px solid #4A96D5;   
   border-bottom: 1px solid #4A96D5;
}

button {
  background: #97C8F1;
  color: #fff;
  padding: 10px 20px;
  letter-spacing: 1.5px;
  cursor: pointer;
}

button:hover{
  background: #2A7BBE;
}

#units, #units2{
  margin-top: 50px;
}

#sky {
  text-transform:capitalize;  
}
            
          
!
            
                var temp_c;
  var temp_f;

  jQuery(document).ready(function($) {

    $("#search").click(function() {

      var cityName = $("#cityName").val();

      $.ajax({
        url: "http://api.wunderground.com/api/88b85d9c3500e9e0/geolookup/conditions/q/IA/" + cityName + ".json",
        dataType: "jsonp",
        success: function(parsed_json) {
          var location = parsed_json['location']['city'];
          var countryName = parsed_json['location']['country_name'];
          var lat = parsed_json['location']['lat'];
          var long = parsed_json['location']['lon'];
          var sky = parsed_json['current_observation']['icon'];
          var icon_url = parsed_json['current_observation']['icon_url'];
          temp_c = Math.floor(parsed_json['current_observation']['temp_c']);
          temp_f = Math.floor(parsed_json['current_observation']['temp_f']);

          $('#locationName').html(location);
          $('#countryName').html(countryName);
          $('#temp').html(temp_c);
          $('#tempUnit').html("&#8451");
          $('#sky').html(sky);
          $('#weatherIcon').attr("src", icon_url).attr("alt", sky);

        }

      });


      $('#cityInput').fadeOut(400).toggleClass("disabled");
      $('#appContainer, #units, #reload').delay(1000).fadeIn(800).toggleClass("disabled");

      $('#units').click(function() {

        $('#temp').html(temp_f);
        $('#tempUnit').html("&#8457");

        $("#units, #units2").toggleClass("disabled");

      });

      $('#units2').click(function() {

        $('#temp').html(temp_c);
        $('#tempUnit').html("&#8451");

        $("#units, #units2").toggleClass("disabled");

      });

    });


    $("#reload").click(function() {
      
      $('#locationName').html("");
      $('#countryName').html("");
      $('#temp').html("");
      $('#sky').html("");
      $('#weatherIcon').attr("src", "");
      $('#cityName').val("");
      
      $('#cityInput').fadeIn(800).toggleClass("disabled");
      $('#appContainer, #units, #reload').delay(1000).fadeOut(800).toggleClass("disabled");

      

    });

  });
            
          
!
999px
Loading ..................

Console