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.

            
              <div class="expandable">
  <button>Expand all</button>
<div class="expandable-item">
    <a class="expandable-item__header js-toggle-expand" role="tab" id="headingpanel-1" href="#panel-1" data-toggle="collapse" aria-expanded="false" aria-controls="panel-1">
        <h3 class="expandable-item__title gamma"><span class="link-text">Expandable item title</span><span class="expandable-item__icon"></span></h3>
    </a>

    <div id="panel-1" class="expandable-item__body" role="tabpanel" aria-expanded="false" aria-labelledby="panel-1">

<p>Vestibulum quis vestibulum neque, ut suscipit eros. Phasellus sagittis ipsum vitae euismod sollicitudin. Vestibulum eu nulla id nisl maximus pharetra. Vivamus bibendum placerat elit. Quisque feugiat sapien ut ante semper, at pellentesque risus laoreet. Aliquam dapibus massa vitae nisi sollicitudin, eget efficitur augue porta. Sed in sem enim.
      </p><p>
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam non est sit amet nunc eleifend ultricies. Suspendisse tristique tempus nibh, ac porttitor magna. Pellentesque urna enim, auctor et aliquet sit amet, consectetur vitae tortor. </p>

    </div>
</div>
  
  <div class="expandable-item">
    <a class="expandable-item__header js-toggle-expand" role="tab" id="headingpanel-2" href="#panel-2" data-toggle="collapse" aria-expanded="false" aria-controls="panel-2">
        <h3 class="expandable-item__title gamma"><span class="link-text">Another expandable item title</span><span class="expandable-item__icon"></span></h3>
    </a>

    <div id="panel-2" class="expandable-item__body" role="tabpanel" aria-expanded="false" aria-labelledby="panel-2">
<p>
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam non est sit amet nunc eleifend ultricies. Suspendisse tristique tempus nibh, ac porttitor magna. Pellentesque urna enim, auctor et aliquet sit amet, consectetur vitae tortor. </p>
<p>Vestibulum quis vestibulum neque, ut suscipit eros. Phasellus sagittis ipsum vitae euismod sollicitudin. Vestibulum eu nulla id nisl maximus pharetra. Vivamus bibendum placerat elit. Quisque feugiat sapien ut ante semper, at pellentesque risus laoreet. Aliquam dapibus massa vitae nisi sollicitudin, eget efficitur augue porta. Sed in sem enim.
      </p>

    </div>
</div>
</div>
            
          
!
            
              'use strict';

var Expandable = {
  init: function() {
    var that = this;

    that.expandable = $('.expandable');
    
    
    
    that.expandable.on('click', 'button', function (event) {
      var expandButton = $(this);
      
      expandButton.toggleClass('open');
      
      if (expandButton.hasClass('open')) {
        expandButton.text('Close all');
        that.expandable.find('.expandable-item').addClass('expandable-item--open') 
      that.expandable.find('.expandable-item__body').show()
      } else {
        expandButton.text('Expand all');
        that.expandable.find('.expandable-item').removeClass('expandable-item--open') 
        that.expandable.find('.expandable-item__body').hide()
      }
    });
    
    

    //Handle changing display on panel headers when open
    that.expandable.on('click', '.js-toggle-expand', function(event) {

      event.preventDefault();

      var expandableItem = $(this).closest('.expandable-item');

      if (expandableItem.hasClass('expandable-item--open')) {
        that.closeExpandableItem(expandableItem);

      } else {
        if (that.expandable.hasClass('expandable--single')) {
          that.closeExpandableItem(expandableItem.siblings('.expandable-item'));
        }
        that.openExpandableItem(expandableItem);
      }
    });
  },

  openExpandableItem: function(expandableItem) {
    var expandableItemBody = expandableItem.find('.expandable-item__body');

    expandableItemBody.attr('aria-expanded', 'true');
    expandableItem.addClass('expandable-item--open');
    expandableItemBody.slideDown(200, function() {
      // hacky IE8 fix to force redraw of changed inline-block element
      expandableItem.closest('.grid__item').toggleClass('foo');
      expandableItem.closest('.grid__item').toggleClass('foo');
    });
  },

  closeExpandableItem: function(expandableItem) {
    var expandableItemBody = expandableItem.find('.expandable-item__body');

    expandableItemBody.attr('aria-expanded', 'false');
    expandableItem.removeClass('expandable-item--open');
    expandableItemBody.slideUp(200, function() {
      // hacky IE8 fix to force redraw of changed inline-block element
      expandableItem.closest('.grid__item').toggleClass('foo');
      expandableItem.closest('.grid__item').toggleClass('foo');
    });
  },

  showAllExpandableItems: function() {
    var expandableItems = this.expandable.find('.expandable-item');

    for (var i = 0, il = expandableItems.length; i < il; i++) {
      this.openExpandableItem($(expandableItems[i]));
    }
  }
};

// initialize
Expandable.init();
            
          
!
999px
Loading ..................

Console