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 id="colour">

<div class="container">
  The weather outside is:
</div>

<div class="weatherbox">
  <span class="weather temp" id="temp">
  </span>
  <span id="unit" class="weather unit"></span>
  <div class="weather desc" id="desc">Loading...</div>
</div>

<div class="container">
  <button id="f">ºF</button>
  <button id="c">ºC</button>
</div>
</div>
            
          
!
            
              * {
  letter-spacing: 2px;
  font-family: monospace;
  font-size: 30px;
  text-align: center;
  padding: 50px;
  color:black;
}

#colour {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  padding: 0;
}

button {
  padding: 10px;
  border-radius: 50%;
  border: none;
  background-color: rgba(0,0,0,0.1);
}

.weatherbox {
  width: 400px;
  margin: 0 auto;
  background-color: rgba(0,0,0,0.1);
  border-radius: 10px;
}

.weather {
  padding: 10px;
  font-size: 40px;
  
}

.temp {
    font-size: 80px;
    padding: 0px;
}

button:hover {
  
  background-color: rgba(0,0,0,0.2);
}

.unit {
  padding: 0px;
  margin: 0px;
  vertical-align: super;
}

            
          
!
            
                  var blank = [Math.floor((Math.random() * 255) + 1), Math.floor((Math.random() * 255) + 1), Math.floor((Math.random() * 255) + 1)];
    var colour = document.getElementById("colour");
    colour.style.backgroundColor = "rgb(" + blank.toString() + ")";

    var temp = document.getElementById("temp");
    var desc = document.getElementById("desc");
    var unit = document.getElementById("unit");
    var f = document.getElementById("f");
    var c = document.getElementById("c");
    c.style.display = "none";
    unit.style.visibility = "hidden";
    unit.innerHTML = "ºC";
    var celsius;

    $(document).ready(function() {

      navigator.geolocation.getCurrentPosition(function(position) {
        var link = "https://weather.millergeek.xyz/data/2.5/weather?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude + "&APPID=8664d7144249b4af03d4f626219de553" + "&units=metric";

        $.getJSON(link, function(data) {
          celsius = Math.round(data.main.temp);
          temp.innerHTML = celsius;
          unit.style.visibility = "visible";
          desc.innerHTML = data.weather[0].description;

          var rgb;

          if (celsius >= 30) {
            rgb = [245, 132, 75];
          } else if (celsius >= 25) {
            rgb = [252, 183, 81];
          } else if (celsius >= 20) {
            rgb = [252, 214, 103];
          } else if (celsius >= 15) {
            rgb = [245, 221, 134];
          } else if (celsius >= 10) {
            rgb = [235, 227, 162];
          } else if (celsius >= 5) {
            rgb = [220, 232, 193];
          } else if (celsius >= 0) {
            rgb = [199, 229, 205];
          } else if (celsius >= -5) {
            rgb = [166, 217, 197];
          } else if (celsius >= -10) {
            rgb = [138, 201, 188];
          } else {
            rgb = [127, 183, 177];
          }

          setInterval(function() {
            for (var i = 0; i < 3; i++) {
              if (blank[i] > rgb[i]) {
                blank[i] -= 1;
              } else if (blank[i] < rgb[i]) {
                blank[i] += 1;
              }
              colour.style.backgroundColor = "rgb(" + blank.toString() + ")";

            }
          }, 20);

        });
      });

      f.onclick = function() {
        temp.innerHTML = Math.round((celsius * 9) / 5 + 32);
        unit.innerHTML = "ºF";
        f.style.display = "none";
        c.style.display = "inline";
      };

      c.onclick = function() {
        temp.innerHTML = celsius;
        unit.innerHTML = "ºC";
        c.style.display = "none";
        f.style.display = "inline";
      };

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

Console