css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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="full-page">
  <div class="layer" id="layerDiv">
  <div class="text-center">
    <h1 class="font-main">Weather</h1>

    <div class="row">
      <div class="columns small-centered small-4 medium-3 large-2">
        <ul class="button-group even-2 toggle round" data-toggle="buttons-radio">
            <input type="radio" id="r1" name="r-group" checked data-toggle="button">
            <label class="button tiny unitBtn" for="r1"><span class="show-for-sr">&deg;C</span><i class="wi wi-celsius unitIcon"></i></label>
            <input type="radio" id="r2" name="r-group" data-toggle="button">
            <label class="button tiny unitBtn" for="r2"><span class="show-for-sr">&deg;F</span><i class="wi wi-fahrenheit unitIcon"></i></label>
    <!-- where the real shit happens
    <div class="display">
      <div class="columns small-12">
        <h2 class="font-secondary" id="location"></h2>
        <h3 class="font-secondary" id="description"></h3>
        <div class="columns small-12 medium-6 large-4  small-centered">

          <div class="columns small-12">
            <i id="mainIcon" class="animated fadeInUp wi"></i>
            <h2 class="font-secondary" id="temp"><span id="units"></span></h2>

          <div class="columns small-12 extra-info">
            <div class="columns small-4">
              <i class="wi wi-humidity"></i>
              <h4 class="font-secondary" id="humidity"></h4>
            <div class="columns small-4">
              <i class="wi wi-barometer"></i>
              <h4 class="font-secondary" id="baroPress"></h4>
            <div class="columns small-4">
              <i class="wi wi-strong-wind"></i>
              <h4 class="font-secondary" id="windSpeed"></h4>

.button {
  background-color: rgba(52, 152, 219, 0.7);
  border-color: rgba(127, 140, 141, 1.0);

.unitIcon {
  font-size: 2em;

input[type="checkbox"] + label,
input[type="radio"] + label {
  display: inline-block;
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 15px;

input[data-toggle] {
  display: none;

input[data-toggle]:checked + label,
input[data-toggle]:checked + label:active {
  background-color: rgba(250, 128, 114, 0.8);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset, 0 1px 2px rgba(0, 0, 0, 0.05);

#mainIcon {
  margin: 1.5rem 0 0.5rem 0;
  color: #fff;
  text-shadow: 2px 2px #000;
  font-size: 4em;

#temp {
  margin-bottom: 2rem;

.font-main {
  font-family: 'josefin sans', sans-serif;
  color: #ffffff;
  text-shadow: 2px 2px #000;
  font-size: 5em;

.font-secondary {
  font-family: 'Open Sans', sans-serif;

ul {
  list-style-type: none;

.extra-info i {
  font-size: 2em;

.border {
  border: 1px solid black;

.full-page {
  height: 100vh;
  min-height: 100%;
  background-size: cover;

.layer {
  background-color: rgba(236, 240, 241, 0.3);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
              $(document).ready(function() {
  var lat,
  var units = "&units=metric";
  var unitPick = "C&deg;";
  var windUnit = "m/s";
  var pressureUnit = "mb";


  // Get location with geolocation
  function getLocation() {

    if (!navigator.geolocation) {
      console.log("geo error");

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

    function error() {


    navigator.geolocation.getCurrentPosition(success, error);

  // Get location with IPinfo
  function altLocation() {
    $.getJSON('http://ipinfo.io', function(data) {

      lat = data.loc[0];
      lon = data.loc[1];
      location = data.city;

  // Unit buttons
  $(".unitBtn").on("click", function() {
    unitPick = $(this).text();
    if (unitPick.indexOf("C") !== -1) {
      units = "&units=metric";
      windUnit = "m/s";
      pressureUnit = "mb";
    } else if (unitPick.indexOf("F") !== -1) {
      units = "&units=imperial";
      windUnit = "mph";
      pressureUnit = "inHg";


  function getWeather() {
    $.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=' + lat + '&lon=' + lon + '&APPID=977c47562a4c5893ea88bbca1c425e98&mode' + units, function(json) {

      var html = "";

      var temperature = Math.round(json.main.temp);
      var description = json.weather[0].description;
      var weatherID = json.weather[0].id;
      var iconClass = "wi-owm-" + weatherID;
      var baroPress = json.main.pressure;
      var humidity = json.main.humidity;
      var windSpeed = json.wind.speed;
      iconID = json.weather[0].icon;


      // use geolocation Location if IPinfo location returns empty
      if (location === undefined) {
         location = json.name;
      $("#temp").html(temperature + unitPick);
      $("#humidity").html(humidity + "%");

      // Pressure conversion 
      if (pressureUnit == "mb") {
        baroPress = json.main.pressure;
      } else if (pressureUnit == "inHg") {
        baroPress = baroPress * 0.0295300;

      $("#baroPress").html(Math.round(baroPress) + pressureUnit);
      $("#windSpeed").html(Math.round(windSpeed) + windUnit);


  // Set weather specific background image

  function getStyle() {
    var imageURL,
    switch (iconID) {
      // Clear Sky
      case "01d":
        imageURL = "https://images.unsplash.com/photo-1448818583842-3353f177e9b4?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=091181f8bc5f9453930919a7017f41d9";
      case "01n":
        imageURL = "https://images.unsplash.com/photo-1444080748397-f442aa95c3e5?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=209d2d52469dec829b005b9bbf7b102d";
        textColor = "white";

        // Few clouds
      case "02d":
        imageURL = "https://images.unsplash.com/photo-1430778569142-43551f375f9a?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=cf9dd773103c393bd80b07910801dbd3";
      case "02n":
        imageURL = "https://images.unsplash.com/photo-1429305336325-b84ace7eba3b?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=3a86834eb7f4628c1f2ef234ee4d8279";
        textColor = "white";

        // Scatered Clouds
      case "03d":
        imageURL = "https://images.unsplash.com/uploads/1412455906842d646f1ce/7bf17d33?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=cfd6d4bc76c77f002a4628a76fb1efcb)";
      case "03n":
        imageURL = "url(https://images.unsplash.com/photo-1452837850452-3974eda0fbe4?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=36da18310fcfb6566062937d0d415bf9";

        // Broken clouds?? Open weather api uses a dark cloud icon.. So that's what the images will show.. 
      case "04d":
        imageURL = "https://images.unsplash.com/photo-1447523264591-68112eb55c23?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=03edf887ebb77cdda57c035140984778";
      case "04n":
        imageURL = "https://images.unsplash.com/photo-1450766166778-e0a0e092d71b?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=eca9290828e5741ddc8668fb6dab72da";
        textColor = "white";

        // Shower Rain
      case "09d":
        imageURL = "https://images.unsplash.com/photo-1457463968646-bbb6184dfedb?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=f7bd6d471031f5cdf1dcb42e6d5049ad";
      case "09n":
        imageURL = "https://images.unsplash.com/photo-1417008914239-59b898b49382?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=88d1c758b1ada959ba8f0c8c54ec44e1";

        // Rain
      case "10d":
        imageURL = "https://images.unsplash.com/photo-1438449805896-28a666819a20?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=75c6aea928bd3f4ab1daef5a797ec20d";
      case "10n":
        imageURL = "https://images.unsplash.com/photo-1449175334484-66563eaeec14?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=44e5ed1ea39077924b931f381b80e5dc";

        // Thunderstorm
      case "11d":
        imageURL = "https://images.unsplash.com/photo-1432927994002-af88b5da76a2?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=9b62b314102774e705bf166e9f6f9a71";
      case "11n":
        imageURL = "https://images.unsplash.com/photo-1447829172150-e5deb8972256?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=8f16ff0419362d842e41375d92ff8cf4";

      case "13d":
        imageURL = "https://images.unsplash.com/photo-1431036101494-66a36de47def?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=56cdaadbf92590359edea1972024429a";
      case "13n":
        imageURL = "https://images.unsplash.com/photo-1423853978401-35df4077ff7d?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=6e753bb049e8cd68f4f981dcf11584d6";

        // Mist Fog
      case "":
        imageURL = "https://images.unsplash.com/photo-1430921688227-2c59c6489072?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=fcb5e015eba5d1af650a33da7a6ebe1f";
      case "":
        imageURL = "https://images.unsplash.com/23/do-the-dew.JPG?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&w=1080&fit=max&s=285e811bdef8560d7b47ceed1da5dec9";

    $(".full-page").css("background-image", "url(" + imageURL + ")");
    $(".font-main, .font-secondary, body").css("color", textColor)
}); // End doc ready
🕑 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.
Loading ..................