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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              .accordion 
  h2.accordion__title Boom! Accordion!
  ul.accordion__list
    li.accordion__item
      .accordion__itemTitleWrap
        h3.accordion__itemTitle Chartreuse drinking vinegar
        .accordion__itemIconWrap.
          <svg viewBox="0 0 24 24"><polyline fill="none" points="21,8.5 12,17.5 3,8.5 " stroke="#FFF" stroke-miterlimit="10" stroke-width="2"/></svg>
      .accordion__itemContent
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
        
    li.accordion__item
      .accordion__itemTitleWrap
        h3.accordion__itemTitle Hoodie pabst trust fund fap organic
        .accordion__itemIconWrap.
          <svg viewBox="0 0 24 24"><polyline fill="none" points="21,8.5 12,17.5 3,8.5 " stroke="#FFF" stroke-miterlimit="10" stroke-width="2"/></svg>
      .accordion__itemContent
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it.
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 

    li.accordion__item
      .accordion__itemTitleWrap
        h3.accordion__itemTitle Keytar synth salvia cred
        .accordion__itemIconWrap.
          <svg viewBox="0 0 24 24"><polyline fill="none" points="21,8.5 12,17.5 3,8.5 " stroke="#FFF" stroke-miterlimit="10" stroke-width="2"/></svg>
      .accordion__itemContent
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it.
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
    li.accordion__item
      .accordion__itemTitleWrap
        h3.accordion__itemTitle Hashtag jean short
        .accordion__itemIconWrap.
          <svg viewBox="0 0 24 24"><polyline fill="none" points="21,8.5 12,17.5 3,8.5 " stroke="#FFF" stroke-miterlimit="10" stroke-width="2"/></svg>
      .accordion__itemContent
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it. 
        p Asymmetrical keytar synth salvia cred gluten-free. Single-origin coffee food truck banh mi vice microdosing, helvetica salvia hoodie pabst trust fund fap organic green juice literally. Hashtag jean shorts banh mi put a bird on it.
    

      
            
          
!
            
              html {
  height: 100%;
}

body {
  font-family: Helvetica, arial, sans-serif;
  background-color: #000;
  height: 100%;
  background: linear-gradient(to bottom, #020111 10%,#3a3a52 100%);
}

.accordion {
  
  & {
    max-width: 500px;
    margin: 0 auto;
  }
  
  &__title {
    font-family: 'industry', sans-serif;
    font-weight: 300;
    color: #fff;
    text-transform: uppercase;
    font-size: 1.125em;
  }
  
  &__list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  &__item {
    border-bottom: 1px solid #000;
    visibility: hidden;
    
    &:last-child {
      border-bottom: 0;
    }
    
    &.is-active {
      
      .accordion__itemTitleWrap {
        
        &::after {
          transform: translateX(-20%);
        }        
      }
      
      .accordion__itemIconWrap {
        transform: rotate(180deg);
      }
    }
  }
  
  &__itemTitleWrap {
    display: flex;
    height: 2.5em;
    align-items: center;
    padding: 0 1em;
    color: #fff;
    cursor: pointer;
    position: relative;   
    overflow: hidden;
    
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 200%;
      height: 100%;
      background: rgba(59,173,227,1);
      background: linear-gradient(
        45deg, 
        rgba(59,173,227,1) 0%, 
        rgba(87,111,230,1) 25%, 
        rgba(152,68,183,1) 51%, 
        rgba(255,53,127,1) 100%
      );
      z-index: 1;      
      transition: transform .4s ease;
    }
    
    &.is-active,
    &:hover {
      
      &::after {
        transform: translateX(-20%);
      }
    }
  }
  
  &__itemIconWrap {
    width: 1.25em;
    height: 1.25em;
    margin-left: auto;
    position: relative;
    z-index: 10;
  }
  
  &__itemTitle {
    margin: 0;
    font-family: 'industry', sans-serif;
    font-weight: 300;
    font-size: 1em;
    position: relative;
    z-index: 10;
  }
  
  &__itemContent {
    font-size: 0.875em;
    height: 0;
    overflow: hidden;
    background-color: #fff;
    padding: 0 1.25em;
    
    p {
      margin: 2em 0;
    }
  }
}
            
          
!
            
              var Accordion = function() {
  
  var
    toggleItems,
    items;
  
  var _init = function() {
    toggleItems     = document.querySelectorAll('.accordion__itemTitleWrap');
    toggleItems     = Array.prototype.slice.call(toggleItems);
    items           = document.querySelectorAll('.accordion__item');
    items           = Array.prototype.slice.call(items);
    
    _addEventHandlers();
    TweenLite.set(items, {visibility:'visible'});
    TweenMax.staggerFrom(items, 0.9,{opacity:0, x:-100, ease:Power2.easeOut}, 0.3)
  }
  
  var _addEventHandlers = function() {
    toggleItems.forEach(function(element, index) {
      element.addEventListener('click', _toggleItem, false);
    });
  }
  
  var _toggleItem = function() {
    var parent = this.parentNode;
    var content = parent.children[1];
    if(!parent.classList.contains('is-active')) {
      parent.classList.add('is-active');
      TweenLite.set(content, {height:'auto'})
      TweenLite.from(content, 0.6, {height: 0, immediateRender:false, ease: Back.easeOut})
      
    } else {
      parent.classList.remove('is-active');
      TweenLite.to(content, 0.3, {height: 0, immediateRender:false, ease: Power1.easeOut})
    }
  }
  
  return {
    init: _init
  }
  
}();

Accordion.init();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console