123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="jumbotron  container-fluid">
  <h1>Weather Application</h1>
</div>
<div class="container">
  <div class='card'>
    <h2> Click Button</h2>
    <span id="hand" class="glyphicon glyphicon-hand-down"></span>
    <button type="button" id="myBtn" class="btn btn-info" data-toggle="modal" data-target="#myModal">Show Weather</button>
  </div>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-body" id="getModalWeather">
        <div class="col-xs-8 col-xs-offset-2">
          <div class="text-center status">
            <p class="textColor"><span id="city"></span> <span id="country"></span></p>
            <p><span id="temp"></span><span class="temp" id="tempunit"></span></p>
            <p id="desc"></p>
          </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>
          <!--   <p class="text-center"> Animated Icons by <a href="https://codepen.io/joshbader/full/EjXgqr/" target="_blank">joshbader</a></p> -->
        </div>
      </div>
      <!-- Modal footer-->

    </div>
  </div>
</div>
            
          
!
            
              .jumbotron {
   background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/45544/background-svg.svg");
    no-repeat top center;
    background-size: cover;
}

.jumbotron h1 {
  color: white;
  font-family: alder bold, sans-serif,;
  font-size: 90px;
  font-weight: 200;
  margin-top: 9px;
  text-transform: uppercase;
  margin-left: 0;
  margin-right: 0;
  text-align: center;
}

.jumbotron  p {
  color: white;
  font-size: 25px;
  font-weight: 400;
  font-family: 'Courgette', cursive;
  text-align: center;
}

.container h2 {
    text-align: center;
    font-size: 70px;
    font-family: 'Dosis', sans-serif;
}

.container #hand {
    font-size: 45px;
    display:block;
    text-align:center;
    margin-top: 5%;
    margin-bottom: 5%;
}
.container #myBtn {
    font-size: 45px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 4%;
}
 .container .card {
  display: flex;
  padding: 40px 85px 90px;
  max-width: 8000px;
  box-shadow: 5px 15px 25px 12px;
  text-align: left;
  background: #fff;
  border-bottom: 4px solid #ccc;
  border-radius: 15px;
  margin-bottom: 35px;
}

@media screen and (max-width: 900px) {
.jumbotron h1 {
    font-size: 40px;
  }
  .container #myBtn {
     font-size: 15px;
     display: block;
     margin-left: auto;
     margin-right: auto;
  }
  
    .container #hand {
     font-size: 20px;
     display: block;
     margin-left: auto;
     margin-right: auto;
  }
  
  .container h2 {
   font-size: 40px;
  }
  
  .modal-body{ 
    height: 350px;
    font-size: 10px;
  }
  .status p {
  font-size: 5px;
  text-transform: capitalize;
  color: white;
}

  }
}

.modal-body  {
  background: black;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px; 
 }

.modal-content  {
    background: black;
    -webkit-border-radius: 30px;
    -moz-border-radius: 30px;
    border-radius: 30px; 
}


   /***************************************************/
          /* Inspired By joshbader*/

.status p {
  font-size: 2.8em;
  text-transform: capitalize;
  color: white;
}

.temp{
  cursor:pointer;
  color:#006dcc;
}
.temp:hover{
  color:#005096;
}

.all-icon {
  margin-bottom: 20px;
}

div.hide {
  display: none;
}

.icon {
  color: #161616;
  position: relative;
  display: inline-block;
  width: 12rem;
  height: 10rem;
}

.cloud {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 3.6875rem;
  height: 3.6875rem;
  margin: -1.84375rem;
  background: currentColor;
  border-radius: 50%;
  box-shadow: -2.1875rem 0.6875rem 0 -0.6875rem, 2.0625rem 0.9375rem 0 -0.9375rem, 0 0 0 0.375rem #fff, -2.1875rem 0.6875rem 0 -0.3125rem #fff, 2.0625rem 0.9375rem 0 -0.5625rem #fff;
}

.cloud:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -0.5rem;
  display: block;
  width: 4.5625rem;
  height: 1rem;
  background: currentColor;
  box-shadow: 0 0.375rem #fff;
}

.cloud:nth-child(2) {
  z-index: 0;
  background: #fff;
  box-shadow: -2.1875rem 0.6875rem 0 -0.6875rem #fff, 2.0625rem 0.9375rem 0 -0.9375rem #fff, 0 0 0 0.375rem #fff, -2.1875rem 0.6875rem 0 -0.3125rem #fff, 2.0625rem 0.9375rem 0 -0.5625rem #fff;
  opacity: 0.3;
  -webkit-transform: scale(0.5) translate(6rem, -3rem);
  -ms-transform: scale(0.5) translate(6rem, -3rem);
  transform: scale(0.5) translate(6rem, -3rem);
  -webkit-animation: cloud 4s linear infinite;
  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: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 0.375rem #fff;
  -webkit-animation: spin 12s infinite linear;
  animation: spin 12s infinite linear;
}

.rays {
  position: absolute;
  top: -2rem;
  left: 50%;
  display: block;
  width: 0.375rem;
  height: 1.125rem;
  margin-left: -0.1875rem;
  background: #fff;
  border-radius: 0.25rem;
  box-shadow: 0 5.375rem #fff;
}

.rays:before,
.rays:after {
  content: '';
  position: absolute;
  top: 0rem;
  left: 0rem;
  display: block;
  width: 0.375rem;
  height: 1.125rem;
  -webkit-transform: rotate(60deg);
  -ms-transform: rotate(60deg);
  transform: rotate(60deg);
  -webkit-transform-origin: 50% 3.25rem;
  -ms-transform-origin: 50% 3.25rem;
  transform-origin: 50% 3.25rem;
  background: #fff;
  border-radius: 0.25rem;
  box-shadow: 0 5.375rem #fff;
}

.rays:before {
  -webkit-transform: rotate(120deg);
  -ms-transform: rotate(120deg);
  transform: rotate(120deg);
}

.cloud + .sun {
  margin: -2rem 1rem;
}

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

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

.bolt {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 0.5rem;
  margin: -0.875rem 0 0 -0.5rem;
  color: #fff;
  background: #fff;
  opacity: 0.3;
  -webkit-animation: lightning 2s linear infinite;
  animation: lightning 2s linear infinite;
}

.bolt:nth-child(2) {
  width: 0.5rem;
  height: 0.25rem;
  margin: -1.875rem 0 0 -1.5rem;
  -webkit-transform: translate(2.5rem, 2.25rem);
  -ms-transform: translate(2.5rem, 2.25rem);
  transform: translate(2.5rem, 2.25rem);
  opacity: 0.2;
  -webkit-animation: lightning 1.5s linear infinite;
  animation: lightning 1.5s linear infinite;
}

.bolt:before,
.bolt:after {
  content: '';
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  margin: -1.75rem 0 0 -1.25rem;
  border-top: 1.25rem solid transparent;
  border-right: 0.75rem solid;
  border-bottom: 0.75rem solid;
  border-left: 0.5rem solid transparent;
  -webkit-transform: skewX(-10deg);
  -ms-transform: skewX(-10deg);
  transform: skewX(-10deg);
}

.bolt:after {
  margin: -0.25rem 0 0 -0.0125rem;
  border-top: 0.75rem solid;
  border-right: 0.5rem solid transparent;
  border-bottom: 1.25rem solid transparent;
  border-left: 0.75rem solid;
  -webkit-transform: skewX(-10deg);
  -ms-transform: skewX(-10deg);
  transform: skewX(-10deg);
}

.bolt:nth-child(2):before {
  margin: -0.875rem 0 0 -0.75rem;
  border-top: 0.625rem solid transparent;
  border-right: 0.375rem solid;
  border-bottom: 0.375rem solid;
  border-left: 0.25rem solid transparent;
}

.bolt:nth-child(2):after {
  margin: -0.125rem 0 0 0;
  border-top: 0.375rem solid;
  border-right: 0.25rem solid transparent;
  border-bottom: 0.625rem solid transparent;
  border-left: 0.375rem solid;
}

.flake:before,
.flake:after {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -1.25rem 0 0 -1.25rem;
  content: '\2744';
  color: #fff;
  list-height: 1em;
  opacity: 0.2;
  -webkit-animation: spin 8s linear infinite reverse;
  animation: spin 8s linear infinite reverse;
}

.flake:after {
  margin: -0.125rem 0 0 -1.375rem;
  font-size: 1.5rem;
  opacity: 0.4;
  -webkit-animation: spin 14s linear infinite;
  animation: spin 14s linear infinite;
}

.flake:nth-child(2):before {
  margin: -0.875rem 0 0 0.25rem;
  font-size: 1.25rem;
  opacity: 0.2;
  -webkit-animation: spin 10s linear infinite;
  animation: spin 10s linear infinite;
}

.flake:nth-child(2):after {
  margin: 0.5rem 0 0 0.125rem;
  font-size: 2rem;
  opacity: 0.4;
  -webkit-animation: spin 16s linear infinite reverse;
  animation: spin 16s linear infinite reverse;
}
/* Animations */

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

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

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

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

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

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

@-webkit-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;
  }
}

@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;
  }
}
/****************************************************/
            
          
!
            
              $("document").ready(function() {
  var tempUnit = "F";
  var currentTempInCelsius;

  $("#myBtn").click(function() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        var lat = "lat=" + position.coords.latitude;
        var lon = "lon=" + position.coords.longitude;
        getWeather(lat, lon);
      });
    } else {
      console.log("Geolocation is not supported by this browser.");
    }

    //Listen to the user click on the slider to determine which unit to represent and calculate.
    $("#tempunit").on("Click", function() {
      var currentTempUnit = $("#tempunit").text();
      var newTempUnit = currentTempUnit == "F" ? "F" : "C";
      $("#tempunit").text(newTempUnit);
      if (newTempUnit == "F") {
        var fahTemp = Math.round(parseInt($("#temp").text()) * 9 / 5 + 32);
        $("#temp").text(fahTemp + " " + String.fromCharCode(176));
      } else {
        $("#temp").text(currentTempInCelsius + " " + String.fromCharCode(176));
      }
    });
    function getWeather(lat, lon) {
      var baseUrl =
        "https://fcc-weather-api.glitch.me/api/current?" + lat + "&" + lon;

      $.ajax({
        url: baseUrl,
        success: function(result) {
          $("#city").text(result.name + ", ");
          $("#country").text(result.sys.country);
          fahTemp = Math.round(parseInt(result.main.temp) * 9 / 5 + 32);
          //currentTempInCelsius = Math.round(result.main.temp * 10) / 10;
          $("#temp").text(fahTemp + " " + String.fromCharCode(176));
          $("#tempunit").text(tempUnit);
          $("#desc").text(result.weather[0].main);
          IconGen(result.weather[0].main);
                        window.location.reload();

        },
        error: function() {
          alert("Weather For Your Location Not Found!");
        }
      });
    }
    function IconGen(desc) {
      var desc = desc.toLowerCase();
      switch (desc) {
        case "drizzle":
          addIcon(desc);
          break;
        case "clouds":
          addIcon(desc);
          break;
        case "rain":
          addIcon(desc);
          break;
        case "snow":
          addIcon(desc);
          break;
        case "clear":
          addIcon(desc);
          break;
        case "thunderstom":
          addIcon(desc);
          break;
        default:
          $("div.clouds").removeClass("hide");
      }
    }

    function addIcon(desc) {
      $("div." + desc).removeClass("hide");
    }
  });
  //document ready line end
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console