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

              
                <nav class="AlphabetNav">
  <a href="#A">A</a>
  <a href="#B">B</a>
  <a href="#C">C</a>
  <a href="#D">D</a>
  <a href="#E">E</a>
  <a href="#F">F</a>
  <a href="#G">G</a>
  <a href="#H">H</a>
  <a href="#I">I</a>
  <a href="#J">J</a>
  <a href="#K">K</a>
  <a href="#L">L</a>
  <a href="#M">M</a>
  <a href="#N">N</a>
  <a href="#O">O</a>
  <a href="#P">P</a>
  <a href="#Q">Q</a>
  <a href="#R">R</a>
  <a href="#S">S</a>
  <a href="#T">T</a>
  <a href="#U">U</a>
  <a href="#V">V</a>
  <a href="#W">W</a>
  <a href="#X">X</a>
  <a href="#Y">Y</a>
  <a href="#Z">Z</a>
</nav>

<div class="ContactList">
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Amanda Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Brian Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Crystal Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Doug Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Erin Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Frank Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Glinda Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Hank Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Izzy Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Joe Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Kelly Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Leo Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Melody Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Ned Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Ophelie Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Patrick Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Que Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Ronald Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Sara Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Teddy Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Una Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Vince Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Willow Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Xavier Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newgirl-01.svg" />
    <h5 class="Contact-name">Yasmine Smith</h5>
  </section>
  <section class="Contact">
    <img class="Contact-avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-80/newboy-02.svg" />
    <h5 class="Contact-name">Zackary Smith</h5>
  </section>
</div>
              
            
!

CSS

              
                /*
  Our design has a min-width of 310px to work
*/

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

body {
  background: ghostwhite;
  font-family: 'Roboto',sans-serif;
}

.AlphabetNav {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  // Shorthand for flex-wrap and flex-direction
  flex-flow: wrap row;
  padding: .5rem;
  background: ghostwhite;
}

.AlphabetNav a {
  display: flex;
  // Center align the letters within each box
  justify-content: center;
  padding: .5em;
  border-radius: 8px;
  font-size: 1.2em;
  line-height: 1;
  font-weight: 500;
  text-decoration: none;
  color: darkgray;
}

.AlphabetNav a:hover {
  background: #ddd;
  color: #444;
}

.AlphabetNav .active {
  background: #f46353;
  color: white;
}

/*
  Contact List
*/
.ContactList {
  padding: 10em 2rem 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.Contact {
  // Flexbox allows us to easily
  // align the avatar and the name
  display: flex;
  align-items: center;
  width: 90%;
}

.ContactList .Contact {
  margin-bottom: 1.5rem;
}

.Contact-avatar {
  margin: 0 1em 0 0;
  width: 30%;
  min-width: 60px;
  max-width: 100px;
  border-radius: 50%;
  background: #a7c031;
}

.Contact-name {
  margin: 0;
  font-size: 1.3em;
  font-weight: 500;
  color: darkgray;
}

@media (min-width: 400px) {
  .AlphabetNav {
    top: 2vh;
    right: 0;
    height: 90vh;
    width: 9em;
  }
  
  .AlphabetNav a {
    // desired width - margins
    width: calc(100% * 1/3 - .3em); 
  }
  
  .ContactList {
    padding-top: 2rem;
  }
}

@media (min-width: 400px) and (min-height: 600px) {
  .AlphabetNav {
    width: 6em;
  }
  
  .AlphabetNav a {
    width: calc(100% * 1/2 - .5em); 
    margin: .25em;
  }
}

@media (min-width: 800px) {
  // Change AlphabetNav to 
  // work horizontally
  .AlphabetNav {
    top: 0;
    display: flex;
    align-items: flex-start;
    flex-flow: nowrap row;
    justify-content: space-around;
    width: 100%;
    height: auto;
    background: ghostwhite;
  }
  
  .AlphabetNav a {
    margin: .5em 0;
    padding: .5em 0;
  }
  
  .ContactList {
    padding-top: 6rem;
  }
  
  .Contact {
    width: calc(100% * 1/3 - 2rem);
  }
}

@import url(https://fonts.googleapis.com/css?family=Roboto:300,500,400);
              
            
!

JS

              
                $('.AlphabetNav a').click(function(evt) {
  evt.preventDefault();
  
  var $navItem = $(this),
      $contacts = $('.Contact');
  
  $contacts.show();
  
  if ($navItem.hasClass('active')) {
    $navItem.removeClass('active');
  } else {
   $('.AlphabetNav a').removeClass('active');
    $navItem.addClass('active');

    $.each($contacts, function(key, contact) {
      var $contact = $(contact),
          $contactName = $contact.find('.Contact-name'),
          $nameArr = $contactName.text().split(' ');

      console.log($nameArr[0].split('')[0].toLowerCase());

      if ($nameArr[0].split('')[0].toLowerCase() !== $navItem.text().toLowerCase()) {
        $contact.hide();
      }
    }); 
  }
});
              
            
!
999px

Console