cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <!--  gallery 1 -->
<div class="gallery">
  <ul class="gallery__nav gallery__nav1">
    <li class="is-active">Cat</li>
    <li>Contrail</li>
    <li>Drizzle</li>
    <li>Grapes</li>
  </ul>

  <div class="gallery__tab-container gallery__tab-container1">
    <div class="gallery__tab gallery__tab1 is-active">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/cat-nose.jpg" />
      <p>Close up cat nose</p>
    </div>
    <div class="gallery__tab gallery__tab2">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/contrail.jpg" />
      <p>Passing overhead we sailed into tomorrow</p>
    </div>
    <div class="gallery__tab gallery__tab3">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/drizzle.jpg" />
      <p>I heard the rain wash the streets</p>
    </div>
    <div class="gallery__tab gallery__tab4">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/grapes.jpg" />
      <p>Oh the grapes, they had so much WRATH</p>
    </div>
  </div>
</div>

<!--  gallery 2 -->
<div class="gallery">
  <ul class="gallery__nav gallery__nav2">
    <li class="is-active">Oranges</li>
    <li>Shore</li>
    <li>Submerged</li>
    <li>Tulip</li>
  </ul>

  <div class="gallery__tab-container gallery__tab-container2">
    <div class="gallery__tab gallery__tab1 is-active">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/orange-tree.jpg" />
      <p>Pluck an orange from the tree</p>
    </div>
    <div class="gallery__tab gallery__tab2">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/shore.jpg" />
      <p>Approaching the shoreline, waiting for the tide</p>
    </div>
    <div class="gallery__tab gallery__tab3">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/submerged.jpg" />
      <p>Beneath the waves he could still hear them calling</p>
    </div>
    <div class="gallery__tab gallery__tab4">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/tulip.jpg" />
      <p>A present from a dewey morning</p>
    </div>
  </div>
</div>

<!--  gallery 3 -->
<div class="gallery">
  <ul class="gallery__nav gallery__nav3">
    <li class="is-active">Van</li>
    <li>Golden hour</li>
    <li>Flight</li>
    <li>Leaf droplets</li>
  </ul>

  <div class="gallery__tab-container gallery__tab-container3">
    <div class="gallery__tab gallery__tab1 is-active">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/van.jpg" />
      <p>Get in. I'll explain on the road.</p>
    </div>
    <div class="gallery__tab gallery__tab2">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/golden-hour.jpg" />
      <p>Sun's down. Hun's down.</p>
    </div>
    <div class="gallery__tab gallery__tab3">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/flight-formation.jpg" />
      <p>Upwards we soared</p>
    </div>
    <div class="gallery__tab gallery__tab4">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/leaf-droplets.jpg" />
      <p>Must have rained</p>
    </div>
  </div>
</div>

            
          
!
            
              body { font-family: sans-serif; }

.gallery__nav {
  padding: 0;
  display: -webkit-box;
  display: flex;
  flex-wrap: wrap;
}

.gallery__nav li {
  display: block;
  padding: 10px;
  border: 1px solid #DDD;
  margin-right: -1px;
  text-decoration: none;
  cursor: pointer;
  color: #08E;
}

.gallery__nav li:hover {
  background: #EEE;
}

.gallery__nav li.is-active {
  background: #19F;
  color: white;
}

.gallery__tab {
  display: none;
  margin-bottom: 40px;
}

.gallery__tab.is-active {
  display: block;
}

.gallery__tab img {
  display: block;
  height: 240px;
}

            
          
!
            
              $('.gallery').each( function( index ) {
  var number = index + 1;
  var $activeNavItem = $( '.gallery__nav' + number + ' li.is-active' );
  var $activeTab = $( '.gallery__tab-container' + number + ' .gallery__tab.is-active' );
  console.log( index )
  $( '.gallery__nav' + number ).on( 'click', 'li', function( event ) {
    event.preventDefault();
    var $navItem = $( event.currentTarget );
    // update active nav item
    $activeNavItem.removeClass('is-active');
    $activeNavItem = $navItem.addClass('is-active');
    // update active tab
    $activeTab.removeClass('is-active');
    var tabNumber = $navItem.index() + 1; // 1,2,3..
    $activeTab = $( '.gallery__tab-container' + number + ' .gallery__tab' + tabNumber );
    $activeTab.addClass('is-active');
  });
});

            
          
!
999px
Loading ..................

Console