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

              
                
<nav class="navbar fixed-bottom navbar-toggleable-md navbar-inverse">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="container">
  <a class="navbar-brand" href="#"><img src="https://webtechnelson.com/images/logo.png" width="30px" height="30px" alt="logo"> Webtechnelson</a>
  <div class="collapse navbar-collapse justify-content-end" id="navbarNavDropdown">
    <ul class="navbar-nav">
      <li class="nav-item active"><a class="nav-link homeLink" href="#"><i class="fa fa-home fa-lg" aria-hidden="true"></i> Home<span class="sr-only">(current)</span></a></li>
      <li class="nav-item dropup">
       <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-building fa-lg" aria-hidden="true"></i> Helpful Links for this Pen</a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
          <a class="dropdown-item" href="https://www.youtube.com/watch?v=Le5L7tdzZd8" target="_blank"><i class="fa fa-code fa-lg" aria-hidden="true"></i> What are APIs,JSON & AJAX?</a>
          <a class="dropdown-item" href="https://www.freecodecamp.com/challenges/get-json-with-the-jquery-getjson-method" target="_blank"><i class="fa fa-free-code-camp fa-lg" aria-hidden="true"></i> FreeCodeCamp Curriculum</a>
          <a class="dropdown-item" href="https://fcc-weather-api.glitch.me/" target="_blank"><i class="fa fa-terminal fa-lg" aria-hidden="true"></i> FCC Weather API pass-through</a>
          <a class="dropdown-item" href="https://stackoverflow.com/questions/22535186/create-new-image-element-using-the-src-of-image-in-another-div-using-jquery" target="_blank"><i class="fa fa-stack-overflow fa-lg" aria-hidden="true"></i> Stackoverflow-HT create image element with JS</a>
        </div>
      </li>
      <li class="nav-item"><a class="nav-link homeLink" href="https://codepen.io/techednelson/" target="_blank"><i class="fa fa-briefcase fa-lg" aria-hidden="true"></i> My Other Projects</a></li>
      <li class="nav-item dropup">
        <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-commenting fa-lg" aria-hidden="true"></i> Contact & Feedback</a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
          <a class="dropdown-item" href="https://twitter.com/webtechnelson" target="_blank"><i class="fa fa-twitter-square fa-lg" aria-hidden="true"></i> Twitter</a>
          <a class="dropdown-item" href="#"><i class="fa fa-envelope fa-lg" aria-hidden="true"></i> info@webtechnelson.com</a>
        </div>
      </li>
    </ul>
    </div>
  </div>
</nav>

<div class="jumbotron container text-center">
  <h1 class="display-3">Weather App</h1>
  <div id="errorMessage">
      <span id="icon"></span>
       <span id="city"></span>
       <a id="temperature" class="btn btn-muted btn-md text-white" href="#" role="button">Loading</a>
       <span id="degree"></span>
       <span id="summary"></span>
  </div>
</div>

              
            
!

CSS

              
                .full {
    height:100%;
    background: url(https://webtechnelson.com/images/clear-day6.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
nav {
    background-color: #121212;
}

.pointer {
    cursor: pointer;
    cursor: hand;
}

.jumbotron {
    position: absolute;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    background: none;
    color: white;
}

.jumbotron a {
    text-decoration: none;
    color: white;
}

#temperature {
  width: 5rem;
  box-shadow: none;
}

              
            
!

JS

              
                 /*NavBar*/
$(".dropdown-menu").click(function() {
 
       $(".navbar-collapse").collapse("hide");
   
});

$(".homeLink").click(function() {
 
       $(".navbar-collapse").collapse("hide");
   
});

/*Weather App*/
$(document).ready(function() {

if (navigator.geolocation.getCurrentPosition) {
    
  navigator.geolocation.getCurrentPosition(function(position) {
      var latitude = position.coords.latitude;
      var longitude = position.coords.longitude;  
    $.getJSON("https://fcc-weather-api.glitch.me/api/current?lat=" + latitude + "&" + "lon=" + longitude, function(responseText,statusText, xhr) { 
                
      if (statusText == "success") {
        
                switch (responseText.weather[0].main) {
                        
                    case "Clear":
                        $('<img src="https://webtechnelson.com/images/icons/clear-day.svg" '+' >').appendTo('#icon');
                        $("html").css("background-image", "url(https://webtechnelson.com/images/clear-day6.jpg)" );
                        break;
                        
                    case "Clear-night":
                         $('<img src="https://webtechnelson.com/images/icons/clear-night.svg" '+' >').appendTo('#icon');
                         $("html").css("background-image", "url(https://webtechnelson.com/images/clear-night.jpg)" );
                        break;
                        
                    case "Rain":
                         $('<img src="https://webtechnelson.com/images/icons/rain.svg" '+' >').appendTo('#icon');
                        $("html").css("background-image", "url(https://webtechnelson.com/images/rain.jpg)" );
                        break;
                        
                    case "Snow":
                         $('<img src="https://webtechnelson.com/images/icons/snow.svg" '+' >').appendTo('#icon');
                         $("html").css("background-image", "url(https://webtechnelson.com/images/snow.jpg)" );
                        break;
                        
                    case "Sleet":
                        $('<img src="https://webtechnelson.com/images/icons/sleet.svg" '+' >').appendTo('#icon');
                        $("html").css("background-image", "url(https://webtechnelson.com/images/sleet.jpg)" );
                        break;
                        
                    case "Wind":
                         $('<img src="https://webtechnelson.com/images/icons/wind.svg" '+' >').appendTo('#icon');
                         $("html").css("background-image", "url(https://webtechnelson.com/images/wind.jpg)" );
                        break;
                        
                    case "Fog":
                         $('<img src="https://webtechnelson.com/images/icons/fog.svg" '+' >').appendTo('#icon');
                         $("html").css("background-image", "url(https://webtechnelson.com/images/fog.jpg)" );
                        break;
                        
                    case "Cloudy":
                        $('<img src="https://webtechnelson.com/images/icons/cloudy.svg" '+' >').appendTo('#icon');
                        $("html").css("background-image", "url(https://webtechnelson.com/images/cloudy.jpg)" );
                        break;
                        
                    case "Partly-cloudy-day":
                        $('<img src="https://webtechnelson.com/images/icons/partly-cloudy-day.svg" '+' >').appendTo('#icon');
                        $("html").css("background-image", "url(https://webtechnelson.com/images/partly-cloudy-day.jpg)" );
                        break;
                        
                    case "Partly-cloudy-night":
                        $('<img src="https://webtechnelson.com/images/icons/partly-cloudy-night.svg" '+' >').appendTo('#icon');
                        $("html").css("background-image", "url(https://webtechnelson.com/images/partly-cloudy-night.jpg)" );
                        break;
                        
                       }
                 var city = responseText.name;
                var country = responseText.sys.country;

                $("#city").html(city + ", " + country);

                /* Change from celsius to Fahrenheit*/
                var changeTemperature = false;
                
                $("#temperature").html(responseText.main.temp + " °C");

                $("#temperature").click(function() {
                    if(!changeTemperature) {
                        var f = Math.round(responseText.main.temp * 9/5 + 32);
                        $("#temperature").html(f + " °F");
                        changeTemperature = true;
                    } else {
                        $("#temperature").html(responseText.main.temp + " °C");
                        changeTemperature = false;
                    }
                }); 
               
      
          } else {
              $("#errorMessage").html("There was an error requesting the weather for your location, please contact me so I can fix it. You can find me on twitter or by email clicking on Contact & Feedback. Thanks");
              }     
                
            });
      
        }); 
    } 
});
   
              
            
!
999px

Console