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="masthead">
    <img src="http://savorypixel.com/147447/img/logo.png">
  </div>
  <div class="top">
    <div class="pane row-1 col-1"></div>
    <div class="pane row-1 col-2"></div>
    <div class="pane row-1 col-3"></div>
    <div class="pane row-1 col-4"></div>
    <div class="pane row-1 col-5"></div>
    <div class="pane row-1 col-6"></div>
    <div class="pane row-2 col-1"></div>
    <div class="pane row-2 col-2"></div>
    <div class="pane row-2 col-3"></div>
    <div class="pane row-2 col-4"></div>
    <div class="pane row-2 col-5"></div>
    <div class="pane row-2 col-6"></div>
    <a row="1" col="1" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/red.jpg">
      <img src="http://savorypixel.com/147447/img/darthmaul.png">
      <h1>Darth Maul</h1>
    </a>
    <a row="1" col="3" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/blue.jpg">
      <img src="http://savorypixel.com/147447/img/c3po.png">
      <h1>C3PO</h1>
    </a>
    <a row="1" col="4" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/green.jpg">
      <img src="http://savorypixel.com/147447/img/obiwan.png">
      <h1>Obi-Wan Kenobi</h1>
    </a>
    <a row="1" col="5" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/green.jpg">
      <img src="http://savorypixel.com/147447/img/yoda.png">
      <h1>Yoda</h1>
    </a>
    <a row="1" col="6" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/red.jpg">
      <img src="http://savorypixel.com/147447/img/stormtrooper.png">
      <h1>Stormtrooper</h1>
    </a>
    <a row="2" col="3" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/green.jpg">
      <img src="http://savorypixel.com/147447/img/hansolo.png">
      <h1>Han Solo</h1>
    </a>
    <a row="2" col="4" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/blue.jpg">
      <img src="http://savorypixel.com/147447/img/quigon.png">
      <h1>Qui-Gon Jinn</h1>
    </a>
    <a row="2" col="5" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/blue.jpg">
      <img src="http://savorypixel.com/147447/img/lando.png">
      <h1>Lando Calrissian</h1>
    </a>
    <a row="2" col="6" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/red.jpg">
      <img src="http://savorypixel.com/147447/img/palpatine.png">
      <h1>Emporer Palpatine</h1>
    </a>
    <div class="hoverstop"></div>
    <div class="hoverstop-right"></div>
  </div>
  <div class="bottom">
    <div class="pane row-1 col-1"></div>
    <div class="pane row-1 col-2"></div>
    <div class="pane row-1 col-3"></div>
    <div class="pane row-1 col-4"></div>
    <div class="pane row-1 col-5"></div>
    <div class="pane row-1 col-6"></div>
    <div class="pane row-2 col-1"></div>
    <div class="pane row-2 col-2"></div>
    <div class="pane row-2 col-3"></div>
    <div class="pane row-2 col-4"></div>
    <div class="pane row-2 col-5"></div>
    <div class="pane row-2 col-6"></div>
    <a row="1" col="1" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/red.jpg">
      <img src="http://savorypixel.com/147447/img/bobafett.png">
      <h1>Boba Fett</h1>
    </a>
    <a row="1" col="2" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/blue.jpg">
      <img src="http://savorypixel.com/147447/img/r2d2.png">
      <h1>R2D2</h1>
    </a>
    <a row="1" col="3" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/red.jpg">
      <img src="http://savorypixel.com/147447/img/darthvader.png">
      <h1>Darth Vader</h1>
    </a>
    <a row="1" col="4" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/blue.jpg">
      <img src="http://savorypixel.com/147447/img/ewok.png">
      <h1>Ewok</h1>
    </a>
    <a row="2" col="1" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/blue.jpg">
      <img src="http://savorypixel.com/147447/img/padme.png">
      <h1>Padme Amidala</h1>
    </a>
    <a row="2" col="2" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/green.jpg">
      <img src="http://savorypixel.com/147447/img/lukeskywalker.png">
      <h1>Luke Skywalker</h1>
    </a>
    <a row="2" col="3" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/green.jpg">
      <img src="http://savorypixel.com/147447/img/chewbacca.png">
      <h1>Chewbacca</h1>
    </a>
    <a row="2" col="4" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/red.jpg">
      <img src="http://savorypixel.com/147447/img/jabba.png">
      <h1>Jabba the Hutt</h1>
    </a>
    <a row="1" col="5" href="#" class="cell">
      <img class="bg-image" src="http://savorypixel.com/147447/img/green.jpg">
      <img src="http://savorypixel.com/147447/img/leia.png">
      <h1>Princess Leia</h1>
    </a>
    <div class="hoverstop"></div>
    <div class="hoverstop-right"></div>
  </div>
  <div class="hoverstop-bottom"></div>
              
            
!

CSS

              
                @font-face {
    font-family: AntennaBlack;
    src: url('http://savorypixel.com/147447/fonts/antenna-black.eot?#iefix') format('embedded-opentype'),
         url('http://savorypixel.com/147447/fonts/antenna-black.woff') format('woff'),
         url('http://savorypixel.com/147447/fonts/antenna-black.ttf')  format('truetype'),
         url('http://savorypixel.com/147447/fonts/antenna-black.woff#AntennaBlack') format('svg');
    font-weight: 700;
    font-style: normal;
  }
  @font-face {
    font-family: AntennaMed;
    src: url('http://savorypixel.com/147447/fonts/antenna-med.eot?#iefix') format('embedded-opentype'),
         url('http://savorypixel.com/147447/fonts/antenna-med.woff') format('woff'),
         url('http://savorypixel.com/147447/fonts/antenna-med.ttf')  format('truetype'),
         url('http://savorypixel.com/147447/fonts/antenna-med.svg#AntennaMedium') format('svg');
    font-weight: 700;
    font-style: normal;
  }
  html {
    overflow-x: hidden;
  }
  body {
    background: #000 url(http://savorypixel.com/147447/img/stars.jpg) 0 0 repeat;
    margin: 0;
    padding: 0;
  }
  .masthead {
    display: none;
    margin: 0 auto;
    padding: 15px 0;
    text-align: center;
  }
  .masthead a {
    color: white;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    position: relative;
    top: -78px;
    left: 150px;
  }
  .bottom,
  .top {
    background-color: #000;
    height: 322px;
    margin: 0 auto;
    position: relative;
    width: 1261px;
  }
  .top {
    margin-top: 20px;
  }
  .pane,
  .cell {
    display: block;
    margin: 0;
    padding: 0;
    position: absolute;
  }
  .pane {
    border: 1px solid #222;
    height: 160px;
    width: 209px;
  }
  .cell {
    background-color: #000;
    height: 160px;
    overflow: hidden;
    text-decoration: none;
    width: 209px;
    z-index: 1;
  }
  .cell img {
    border: 0;
    height: 100%;
    outline: none;
    width: 100%;
  }
  .bg-image {
    left: 0;
    position: absolute;
    top: 0;
    opacity: 0;
    z-index: -1;
  }
  h1{
    bottom: 20px;
    color: #fff;
    display: none;
    font-family: AntennaBlack, Arial, Helvetica, sans-serif;
    font-size: 36px;
    font-weight: bold;
    left: 25px;
    margin: 0;
    padding: 0;
    position: absolute;
    text-shadow: 1px 0px #111, 0px 1px #333,
                 2px 1px #111, 1px 2px #333,
                 3px 2px #111, 2px 3px #333,
                 4px 3px #111, 3px 4px #333,
                 5px 4px #111, 4px 5px #333,
                 6px 5px #111, 5px 6px #333,
                 7px 6px #111, 6px 7px #333,
                 8px 7px #111, 7px 8px #333,
                 8px 8px #111;
    filter: progid:DXImageTransform.Microsoft.Shadow(color=#000000,direction=135,strength=5);

  }
  .row-1 {
    top: 0;
  }
  .row-2 {
    top: 161px;
  }
  .col-1 {
    left: 0;
  }
  .col-2 {
    left: 210px;
  }
  .col-3 {
    left: 420px;
  }
  .col-4 {
    left: 630px;
  }
  .col-5 {
    left: 840px;
  }
  .col-6 {
    left: 1050px;
  }
  .top .hoverstop,
  .bottom .hoverstop {
    border: 0;
    cursor: pointer;
    height: 321px;
    left: 1261px;
    position: absolute;
    top: 1px;
    width: 419px;
    z-index: 5000;
  }
  .top .hoverstop-right,
  .bottom .hoverstop-right {
    border: 0;
    height: 323px;
    left: 1261px;
    position: absolute;
    top: 0;
    width: 210px;
    z-index: 5000;
  }
  .hoverstop-bottom {
    height: 160px;
    margin: 1px auto 0;
    position: relative;
    width: 1680px;
    z-index: 5000;
  }
              
            
!

JS

              
                $(document).ready(function(){

  $('.cell:not(.selected)').hoverIntent(function(){
    shiftCells($(this));
  }, 30, function(){});

  initialSetup();

});

function shiftCells($this){

  var container = '.' + $this.parent().attr('class') + ' ',
      prevSelectedRow = parseInt($(container + '.selected').attr('row')),
      prevSelectedCol = parseInt($(container + '.selected').attr('col'));

  $(container + '.cell').removeClass('selected');
  $this.addClass('selected');

  var curSelectedRow = parseInt($(container + '.selected').attr('row')),
      curSelectedCol = parseInt($(container + '.selected').attr('col'));

  $('.cell').css("z-index", '');
  $(container + '.selected').css("z-index", '100');

  if(curSelectedRow === 1 && curSelectedCol > prevSelectedCol){
    $(container + '.cell').each(function(){
      var row = parseInt($(this).attr('row')),
          col = parseInt($(this).attr('col'));
      if(row === 1 && col <= curSelectedCol && col > prevSelectedCol){
        $(this).attr('col', col - 1);
      } else if(row === 2 && col <= curSelectedCol && col > prevSelectedCol){
        $(this).attr('col', col - 2);
      }
    });
  } else if(curSelectedRow === 1 && curSelectedCol < prevSelectedCol){
    $(container + '.cell').each(function(){
      var row = parseInt($(this).attr('row')),
          col = parseInt($(this).attr('col'));
      if(row === 1 && col > curSelectedCol && col <= prevSelectedCol){
        $(this).attr('col', col + 1);
      } else if(row === 2 && col >= curSelectedCol && col < prevSelectedCol){
        $(this).attr('col', col + 2);
      }
    });
  } else if(curSelectedRow === 2 && curSelectedCol > prevSelectedCol){
    $(container + '.cell[row=1][col=' + prevSelectedCol + ']').attr('row', '2');
    $(container + '.cell').each(function(){
      var row = parseInt($(this).attr('row')),
          col = parseInt($(this).attr('col'));
      if(row === 1 && col <= curSelectedCol && col >= prevSelectedCol){
        $(this).attr('col', col - 2);
      } else if(row === 2 && col <= curSelectedCol && col > prevSelectedCol){
        $(this).attr('col', col - 1);
      }
    });
    $(container + '.selected').attr('row', (curSelectedRow - 1)).attr('col', (curSelectedCol - 1));
  } else if(curSelectedRow === 2 && curSelectedCol < prevSelectedCol){
    $(container + '.cell').each(function(){
      var row = parseInt($(this).attr('row')),
          col = parseInt($(this).attr('col'));
      if(row === 1 && col >= curSelectedCol && col <= prevSelectedCol){
        $(this).attr('col', col + 1);
      } else if(row === 2 && col > curSelectedCol && col <= prevSelectedCol){
        $(this).attr('col', col + 2);
      }
    });
    $(container + '.cell[row=1][col=' + (curSelectedCol + 1) + ']').attr('row', curSelectedRow).attr('col', (curSelectedCol + 2));
    $(container + '.selected').attr('row', (curSelectedRow - 1));
  }

  animateCells(750, 750, 50, container);

}

function initialSetup(){

  $('.top a').first().addClass('selected');
  $('.bottom a').last().addClass('selected');

  animateCells(0, 0, 0, '.top ');
  animateCells(0, 0, 0, '.bottom ');

}

function animateCells(movingSpeed, sizingSpeed, delay, container){

  var movingEase = 'easeInOutCubic',
      sizingEase = 'easeOutBack',
      selectedEase = 'easeInOutBack',
      selectedColor = $(container + '.selected').attr('bg'),
      selectedLeft = (parseInt($(container + '.selected').attr('col')) - 1) * 210 + 1 + 'px',
      bgImage = '',
      rowOptions = {queue: false, duration: movingSpeed, specialEasing: {top: movingEase}},
      colOptions = {queue: false, duration: movingSpeed, specialEasing: {left: movingEase}};

  if(selectedColor === 'red'){
    bgImage = 'images/red.jpg';
  } else if(selectedColor === 'blue'){
    bgImage = 'images/blue.jpg';
  } else if(selectedColor === 'green'){
    bgImage = 'images/green.jpg';
  }

  setTimeout(function() {
    $('.cell[row=1]:not(.selected)').animate({
      top: '1px'
    }, rowOptions);
    $('.cell[row=2]:not(.selected)').animate({
      top: '162px'
    }, rowOptions);
    $('.cell[col=1]:not(.selected)').animate({
      left: '1px'
    }, colOptions);
    $('.cell[col=2]:not(.selected)').animate({
      left: '211px'
    }, colOptions);
    $('.cell[col=3]:not(.selected)').animate({
      left: '421px'
    }, colOptions);
    $('.cell[col=4]:not(.selected)').animate({
      left: '631px'
    }, colOptions);
    $('.cell[col=5]:not(.selected)').animate({
      left: '841px'
    }, colOptions);
    $('.cell[col=6]:not(.selected)').animate({
      left: '1051px'
    }, colOptions);
  }, delay);

  $('.cell:not(.selected)').animate({
    height: '160px',
    width: '209px'
  }, {
    queue: false,
    duration: sizingSpeed,
    specialEasing: {
      height: movingEase,
      width: movingEase
    }
  });
  $(container + '.selected').animate({
    height: '321px',
    width: '419px',
    top: '1px',
    left: selectedLeft
  }, {
    queue: false,
    duration: sizingSpeed,
    specialEasing: {
      height: sizingEase,
      width: sizingEase,
      left: selectedEase,
      top: selectedEase
    }
  });

  $('.cell:not(.selected) .bg-image').animate({
    opacity: '0'
  }, {
    queue: false,
    duration: sizingSpeed,
    specialEasing: {
      opacity: sizingEase
    }
  });
  $(container + '.selected .bg-image').animate({
    opacity: '1'
  }, {
    queue: false,
    duration: 1000,
    specialEasing: {
      opacity: sizingEase
    }
  });

  $(container + '.hoverstop').css('left', selectedLeft);
  $('.cell:not(.selected) h1').fadeOut(200);

  setTimeout(function() {
    $(container + '.selected h1').fadeIn();
  }, 700);
}
              
            
!
999px

Console