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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="chicago">
  <div class="container">
    <div class="city-title">Chicago</div>
    <hr />
    <div class="city-weather-temperature"  id="city-weather-temperature">-1° C</div>
    <div class="city-weather-description" id="city-weather-description">
      sunny
    </div>
    
    <img src="http://openweathermap.org/img/w/01d.png" alt="weather-icon" class="city-weather-icon" id="city-weather-icon" />

    
    <div class="content">
    
      <nav>
        <ul>
          <li><a href="#">Hotels</a></li>
          <li><a href="#">Places</a></li>
          <li><a href="#">Restaurants</a></li>
          <li class="selected"><a href="#">Offices</a></li>
        </ul>
      </nav>

      <div class="nav-info clearfix" id="offices">
        <div class="one-half">
          <div class="info" id="offices">
            <div class="company-name">Mintel Group Ltd</div>
            <div class="address">333 W. Wacker Drive, Suite 1100, Chicago</div>
            <div class="phone">+1 123 654 987 36</div>
          </div> <!-- end info -->
        </div> <!-- end one-half -->

        <div class="one-half">
          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office1.png" alt="office 1" />

          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office2.png" alt="office 2" />

        </div> <!-- end one-half -->

      </div> <!-- end nav-info #offices-->
      
      <div class="nav-info clearfix hide" id="restaurants">
        <div class="one-half">
          <div class="info" id="offices">
            <div class="company-name">Restaurant Ltd</div>
            <div class="address">123 E. Licoln Dr., Suite 9874, Chicago</div>
            <div class="phone">+1 564 232 4853 </div>
          </div> <!-- end info -->
        </div> <!-- end one-half -->

        <div class="one-half">
          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office1.png" alt="office 1" />

          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office2.png" alt="office 2" />

        </div> <!-- end one-half -->

      </div> <!-- end nav-info #restaurants-->
      
      <div class="nav-info clearfix hide" id="places">
        <div class="one-half">
          <div class="info" id="offices">
            <div class="company-name">Places</div>
            <div class="address">874 North Street, Suite 2200, Chicago</div>
            <div class="phone">+1 905 265 9876 </div>
          </div> <!-- end info -->
        </div> <!-- end one-half -->

        <div class="one-half">
          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office1.png" alt="office 1" />

          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office2.png" alt="office 2" />

        </div> <!-- end one-half -->

      </div> <!-- end nav-info #places-->
      
      <div class="nav-info clearfix hide" id="hotels">
        <div class="one-half">
          <div class="info" id="offices">
            <div class="company-name">Hotels Ltd</div>
            <div class="address">890 Marina Blvd, Suite 9412, Chicago</div>
            <div class="phone">+1 416 874 9874 </div>
          </div> <!-- end info -->
        </div> <!-- end one-half -->

        <div class="one-half">
          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office1.png" alt="office 1" />

          <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/office2.png" alt="office 2" />

        </div> <!-- end one-half -->

      </div> <!-- end nav-info #hotels-->
      
      <div class="nav-info-behind clearfix">
        
      </div> <!-- end nav-info-behind-->
      
    </div> <!-- end content -->
    
  </div> <!-- end container -->
  
</div> <!-- end chicago -->
              
            
!

CSS

              
                //fonts
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);

@font-face { font-family: 'Intro'; src:url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/Intro.ttf.woff') format('woff'), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/Intro.ttf.svg#Intro') format('svg'), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/Intro.ttf.eot'), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/Intro.ttf.eot?#iefix') format('embedded-opentype'); font-weight: normal; font-style: normal; }

//variables
$select-color: #C4A865;

body {
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/blurred_bg.jpg') no-repeat center center fixed;
  background-size: cover;
}

.chicago {
  box-sizing: border-box;
  font: 13px "Open Sans", Arial;
  padding: 40px 0;
}

*, *:before, *:after {
  box-sizing: inherit;
}

.container {
  margin: 0 auto;
  width: 360px;
  height: 480px;
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/195612/chicago.jpg');
  border-radius: 2px;
  position: relative
  
}

.city-title, .city-weather-temperature, .city-weather-description, img.city-weather-icon {
  font-family: 'Intro';
  text-align: center;
  margin:auto;
  display: block;
}

.city-title {
  font-size: 26px;
  padding-top: 24px;
}

hr {
  border-top: 1px solid #A3A3A3;
  border-bottom: 1px solid #626165;
  width: 112px;
}

.city-weather-temperature {
  font-size: 22px;
  margin-bottom: 10px;
}

.city-weather-description {
  width: 120px;
  margin: auto;
  text-align: center;
}

.content {
  position: absolute;
  bottom: 0px;
  z-index: 9999;
}

nav {
  background: #fffff0;
  padding-left: 0px;
  
  ul {
    padding: 13px 0;
    
    li {
      display: inline;
      padding-left: 20px;
      padding-right: 20px;
      padding-bottom: 11px;
      
      border-color: rgba(0,0,0,0);
      transition: border-color 0.25s linear;

      &.selected {
         border-bottom: 3px solid $select-color;
      }
      
      &:hover {
        border-bottom: 3px solid $select-color;
        border-color: 3px solid rgba(198,168,101,1);
 
      }
      
      &:last-child {
        padding-right: 18px;
      }
      
      a {
        text-decoration: none;
        color: black;
      }
    }
  }
  
} // end nav

.nav-info-behind {
  background: rgba(255,255,240, 0.65);
  z-index: -1;
  height: 130px; 
  width: 360px; 
  position: absolute; 
  bottom: 0;
  
}

.nav-info {
  background: rgba(255,255,240, 0.65);
   
  .info {
    margin-top: 20px;
    margin-bottom: 24px;
    
    .company-name {
      text-transform: uppercase;
      font-weight: bold;
      margin-bottom: 3px;
    }
    
    .address {
      line-height: 16px;
      margin-bottom: 6px;
    }
    
    .phone {
      color: $select-color;
      font-weight: bold;
    }
  }
  
  img {
    margin-top: 28px;
    margin-right: 8px;
  }
}

.one-half {
  width: 180px;
  float: left;
  padding-left: 20px;
}

.clearfix:before,
  .clearfix:after,
  .row:before,
  .row:after {
    content: '\0020';
    display: block;
    overflow: hidden;
    visibility: hidden;
    width: 0;
    height: 0; }
  .row:after,
  .clearfix:after {
    clear: both; }
  .row,
  .clearfix {
    zoom: 1; }


.clear {
  clear: both;
  display: block;
  overflow: hidden;
  visibility: hidden;
  width: 0;
  height: 0;
}

.hide {
  display: none;
}
              
            
!

JS

              
                // weather api
$(document).ready(function() {
  
  $.ajax({
    
    url: "http://api.openweathermap.org/data/2.5/weather?q=chicago,usa&APPID=4573c189d467ca1814c1c10000060792",
    dataType : "json",
    type: "GET", 

    success: function(json) {
      var temp = Math.round(json.main.temp - 273.15);
      $('#city-weather-temperature').html(temp + '° C');
      $('#city-weather-description').html(json.weather[0].description);
      $('img#city-weather-icon').attr('src', 'http://openweathermap.org/img/w/' + json.weather[0].icon + '.png');
    },
    error: function(xhr, status, errorThrown) {
      //do something if there was an error. Right now it will just show the default values in the html
    }
  });
  
  // Nav toggle content
  $("nav ul li a").on("click", function() {
    
    var $this = $(this);
    var target = $this.text().toLowerCase();
    
    //update nav selected
    $this.parent().addClass('selected').siblings().removeClass('selected');
    
    
    //show and hide appropriate content based on selection    
    $('#' + target).fadeIn('slow').removeClass('hide').siblings().not('nav').not('.nav-info-behind').hide();
    
    
    return false;
  });
});
              
            
!
999px

Console