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.

            
              <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<div class="container">
  <label class="collapser">Click on me!</label>
  <div class="collapsee">
    <p>
        This is some example content. It will all be hidden because it is inside a div which is immediately following the collapser.
    </p>
    <p>
        This is the only requirement. IDs and classes don't matter as long as this convention is used.
    </p>
    <p>
        A class "collapsed" is added to the element being clicked on to allow stying of the two states. the "collapsed" class is only present when the element is completely collapsed.
    </p>
</div>
</div>

<div class="container">
  <div class="collapser">
  <span class="collapse-state fa fa-chevron-down"></span><span class="title">Click on me!</span>
  </div>
  <div class="collapsee">
    <p>
        This is some example content. It will all be hidden because it is inside a div which is immediately following the collapser.
    </p>
    <p>
        This is the only requirement. IDs and classes don't matter as long as this convention is used.
    </p>
    <p>
        A class "collapsed" is added to the element being clicked on to allow stying of the two states. the "collapsed" class is only present when the element is completely collapsed.
    </p>
</div>
</div>
            
          
!
            
              .collapser {
    cursor:pointer;
}

/* Prettifying for the demo */
html {
    font-family: helvetical, tahoma, sans-serif;
    font-size:1em;
    box-sizing: content-box;
}

.container {
  width:300px;
}

.container .collapser {
    display:inline-block;
    width:100%;
    color:#FFFFFF;
    padding:8px 16px;
    background-color:#7F0000;
    border-top-left-radius:5px;
    border-top-right-radius:5px;
    border:1px solid #7F0000;
}

.collapser.collapsed {
    border-radius:5px;
}

.collapsee {
    padding:8px 16px;
    width:100%;
    border: 1px solid #7F0000;
    border-radius:0 0 5px 5px;
}

.collapse-state {
    float:right;
    display:inline-block;
    height:1em;
    margin-right:5px;
    transform:rotate(0deg);
    transition:0.3s;
}
.collapsed .collapse-state{
    transform:rotate(-90deg);
    transition:0.3s;
}


            
          
!
            
              $(function () {
	$(".collapser").collapser();
});

(function ($) {
    $.fn.collapser = function () {
        return this.each(function () {
            $(this).click(function () {
                var collapser = $(this);
                var collapsee = $(this).next();
                if (collapser.hasClass("collapsed")) {
                    collapser.removeClass("collapsed");
                    collapsee.slideDown("fast");
                } else {
                    collapsee.slideUp("fast",function () { collapser.addClass("collapsed"); });
                }
            });
        })
    }
})(jQuery)
            
          
!
999px
Loading ..................

Console