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


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


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.


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.


  <div class="container-fluid">
    <div id="currentLocation" class="currentLocation">Loading...</div>
    <div id="weatherIcons" class="weatherIcons">
    <div id="currentWeather" class="currentWeather"></div>
    <div class="currentTemperature"><span id="currentTemperature">&deg;C</span></div>


                body {
  background-color: #007CBD;
  color: #faebd7;
  text-align: center;
  font-family: 'Raleway', sans-serif;
  margin: 50px 0 auto;
  letter-spacing: 3px;
  font-weight: 300;

.container-fluid {
  display: inline-block;

.currentLocation {
  font-size: 300%;
  margin: 25px auto;

.weatherIcons {
  font-size: 120px;
  margin: 0 auto 40px;

.currentWeather {
  margin: 0 auto 25px;
  font-size: 200%;

.currentTemperature {
  font-size: 60px;
  margin: 0 auto 15px;
  display: inline-block;
  cursor: pointer;
  color: #fc3;



                $(document).ready(function() {
  // Check whether browser supports Geolocation API or not
  if (navigator.geolocation) {
    // Supported
  } else {
    // Not supported
    alert("Oops! This browser does not support HTML Geolocation.");

  function getPosition(position) {
    let lat = position.coords.latitude;
    let lon = position.coords.longitude;

    //Call to weather API
    const API_KEY = "e188b6a2a5b9a44694ce486159c34452";
    let url =
      "" +
      lat +
      "&lon=" +
      lon +
      "&APPID=" +
    $.getJSON(url, function(weatherData) {
      let currentLocation =;
      let currentTemperature = Math.floor(weatherData.main.temp);
      let currentWeather =[0].description;
      let weatherIcon =[0].icon;
      let temp_max = Math.floor(weatherData.main.temp_max);
      let temp_min = Math.floor(weatherData.main.temp_min);
      $("#currentTemperature").html(currentTemperature + "°C");

      //Prepend icons into our icon class
      //We want to prepend our ID with an icon depending on the weather

      function getIcon(weatherIcon) {
        let iconsMap = {
          "01d": "wi wi-day-sunny",
          "02d": "wi wi-day-cloudy",
          "03d": "wi wi-day-sunny-overcast",
          "04d": "wi wi-cloud",
          "09d": "wi wi-rain",
          "10d": "wi wi-day-showers",
          "11d": "wi wi-day-thunderstorm",
          "13d": "wi wi-day-snow",
          "50d": "wi wi-day-fog",

          "01n": "wi wi-night-clear",
          "02n": "wi wi-night-partly-cloudy",
          "03n": "wi wi-cloudy",
          "04n": "wi wi-night-cloudy",
          "09n": "wi wi-night-alt-showers",
          "10n": "wi wi-night-rain",
          "13n": "wi wi-night-snow",
          "50n": "wi wi-night-fog"
        return iconsMap[weatherIcon];

      //Convert between C and F
      function getTemperature () {
      let celsius = currentTemperature;
      let fahrenheit = Math.floor(celsius * 1.8 + 32);
      let showF = false;

      $("#currentTemperature").click(function() {
        showF = !showF;
        if (showF) {
          $("#currentTemperature").html(fahrenheit + "°F");
        } else {
          $("#currentTemperature").html(celsius + "°C");

    function setColors() {
    let colors = {
              morning: "#44BFFF",
              noon: "#007CBD",
              night: "#19120A"
    let currentTime = new Date().getHours();
            if (currentTime >= 6 && currentTime <= 12) {
              $("body").css("background-color", colors.morning);
              else if (currentTime >= 12 && currentTime <= 18) {
              $("body").css("background-color", colors.noon);
                else {
              $("body").css("background-color", colors.night);
    }); //getJSON
  } //getPosition
}); //documentReady