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.

            
              <section class="main">
  <header class="title">
    Flexible accordian with psuedo element indicators
  </header>
  <section>
      <button>
        Open
      </button>
    <header>
      Open Me, Please.
    </header>
    <div>
      <article>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet nemo harum voluptas aliquid rem possimus nostrum excepturi!
      </article>
    </div>
  </section>
  <section>
    <button>
        Open
    </button>
    <header>
      Or me...
    </header>
    <div>
      <article>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit.
        <ul>
          <li>Lorem ipsum dolor sit amet.</li>
          <li>Qui explicabo soluta deleniti vel?</li>
          <li>Esse aperiam unde quam cupiditate!</li>
          <li>Laboriosam magnam neque cumque. Nisi.</li>
          <li>Doloremque eum quibusdam sit incidunt.</li>
        </ul>
      </article>
    </div>
  </section>
    <section>
      <button>
        Open
      </button>
    <header>
      You could open <i>me</i> up.
    </header>
    <div>
      <article>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore maxime perspiciatis amet nemo harum voluptas aliquid rem possimus nostrum excepturi! Tempore maxime perspiciatis amet nemo harum voluptas aliquid rem possimus nostrum excepturi!
      </article>
    </div>
  </section>
  <section>
    <button>
        Open
    </button>
    <header>
      Definitely click on me though.
    </header>
    <div>
      <article class="special">
        <img src="http://media.giphy.com/media/hUldButOAGC64/giphy.gif" alt="" />
<h3>Happy Holidays, CodePen!</h3>
      </article>
    </div>
  </section>
</section>
            
          
!
            
              * {
  box-sizing: border-box;
}
body {
  font-family: "Helvetica Neue", Helvetica, sans-serif;
  background: limegreen;
}
section {
  position: relative;
  width: 100%;
  &.main {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40%;
    max-width: 30em;
    min-width: 15em;
    transform: translate(-50%,-50%);
    border-radius: 3px;
    overflow: hidden;
    & > header {
      color: #fff;
      background: darken(limegreen, 20);
      text-align: center;
      font-weight: 700;
      line-height: 1.2em;
    }
  }
  & > section {
    border-bottom: 1px solid lighten(limegreen, 40);
    &:last-child {
      border:none;
    }
  }
  & > div {
    height: 0;
    overflow: hidden;
    transition: all .2s ease-in;
  }
  button {
    position: absolute;
    right: 0;
    margin: 0;
    padding: 0;
    height: 3em;
    width: 3em;
    outline: 0;
    border: 0;
    background: none;
    text-indent: -9999%;
    pointer-events: none;
    &:after, &:before {
      content: '';
      display: block;
      position: absolute;
      height: 12px;
      width: 4px;
      border-radius: .3em;
      background: limegreen;
      transform-origin: 50%;
      top: 50%;
      left: 50%;
      transition: all .3s ease-in-out;
    }
    &:after {
      transform: translate(-75%,-50%) rotate(-45deg);
    }
    &:before {
      transform: translate(75%,-50%) rotate(45deg);
    }
  }
  &.open button {
      &:after,
      &:before {
        height: 14px;
        background: darken(limegreen,10);
      }
      &:after {
        transform: translate(0%,-50%) rotate(45deg);
      }
      &:before {
        transform: translate(0%, -50%) rotate(-45deg);
      }
    }
  &.open header {
    color: #555;
  }
}
article,
header {
  padding: 1em;
  line-height: 1em;
}
header:not(.title) {
  width: 100%;
  overflow: hidden;
  height: 3em;
  background: rgba(255,255,255,1);
  cursor: pointer;
  font-weight: 700;
  color: #888;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-right: 2.1em;
  &:hover {
    background: lighten(limegreen, 45);
  }
}
article {
  line-height: 1.4em;
  font-size: .9em;
  background: rgba(255,255,255,.7);
  img {
    width: 100%;
    height: auto;
    border: 5px solid white;
    border-radius: 3px;
  }
  &.special {
    h3 {
      margin: .35em 0 0 0;
      color: darken(limegreen,15);
      text-align: center;
    }
  }
}

            
          
!
            
              $(document).ready(function(){
  
  $('header').not('.title').on('click', function(){
    
    var that = $(this),
        parent = that.parent(),
        closeDiv = that.siblings('div'),
        contentHeight = closeDiv.children('article').outerHeight();
    
    that.parents('section').first().toggleClass('open');
    (closeDiv.height() === 0) ? closeDiv.height(contentHeight) : closeDiv.height(contentHeight).height(0);
    
    closeDiv.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',   
      function(e) {
        var that = $(this);
        (that.css('height') !== '0px') ? that.css('height','auto') : that.css('height', '0px' );
      });
  });
  
});
            
          
!
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