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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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 id="main">
  <div class="container">
    <div class="left">
        <div class="box-photo bp1">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp2">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp3">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp4">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp5">
          <div class="photo"></div>
        </div>

    </div>

      <div class="right">
         <div class="box-photo bp6">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp7">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp8">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp9">
          <div class="photo"></div>
        </div>

        <div class="box-photo bp10">
          <div class="photo"></div>
        </div>

    </div>
  </div>
</div>

<div id="overlayCont">

</div>

              
            
!

CSS

              
                body {
  background: #222222;
  overflow:hidden;
  }

#main {
  height:100%;
  width:100%;
  position:absolute;
  overflow:auto;
}

#overlayCont {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  
  .photo {
    width:100%;
    height:100%;
  }
}

.container {

  display: flex;
  justify-content: center;
  align-items: center;
  
  .left, .right {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin: 0 15vw;
      width: 45vw;
      
    .box-photo {
      width: 100%;
      height: 55vh;
      margin: 15vh 0;
      cursor: pointer;
      
      .photo {
        width: 100%;
        height: 100%;
      }
    }
  }
}



              
            
!

JS

              
                var main = document.getElementById('main');
var oCont = document.getElementById('overlayCont');

var bp = $('.photo');

// set pictures
for (var i = 0; i < 10; i++)
  TweenMax.set($('.bp'+i+' > .photo'), { 
    backgroundImage:'url(https://unsplash.it/100' + i + ')',
    backgroundSize:'100% 100%'
  });

bp.click(function(){
  if (!oCont.tween) {
    // save parent
    this.oParent = this.parentElement;
    
    // get position on screen
    var dT = this.offsetTop - main.scrollTop;
    var dL = this.offsetLeft - main.scrollLeft;

    // get picture size
    var pW = this.offsetWidth;
    var pH = this.offsetHeight;

    // move picture to overlay
    oCont.appendChild(this);
    
    var tl = new TimelineMax({ 
      onReverseComplete: function () {
        // restore picture
        this.oParent.appendChild(this);
        // and clear tween
        oCont.tween = undefined;
      }.bind(this)
    });
    // save tween to overlay
    oCont.tween = 
      tl.set(oCont, { 
          clearProps: 'all' 
        }, 0.0001)
        .fromTo(oCont, 0.5, { 
          left:dL+'px', 
          top:dT+'px', 
          width:pW+'px', 
          height:pH+'px' 
        },
        {
          left:0, 
          top:0, 
          width:'100%', 
          height:'100%'
        });
    // remember tween playing
    oCont.playing = true;
  }
  else {
    // invert tween
    if (oCont.playing) 
      oCont.tween.reverse();
    else 
      oCont.tween.play();
    // adn remember play/rev
    oCont.playing = !oCont.playing;
  }
});
              
            
!
999px

Console