Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div>
  <p>Click on this first visible paragraph.</p>
  <p>It's harder when the content you want to animate the height of is supposed to be initially closed. 
    Nam at tortor porta, imperdiet mi at, iaculis lorem. Donec mollis faucibus lacinia. Ut mollis tortor vitae lorem malesuada pretium. Suspendisse porta malesuada dui interdum mattis. In malesuada, enim id pulvinar luctus, eros lectus posuere nunc, et eleifend risus velit ac ipsum. Morbi urna est, ornare quis ligula egestas, cursus euismod eros. Cras eu malesuada lacus, at lacinia velit. Fusce a lorem ultrices nunc gravida consectetur. Phasellus vel mollis quam. Vestibulum bibendum, velit quis auctor congue, lectus arcu ultricies velit, vel ullamcorper orci libero ac neque. Suspendisse in orci vitae diam vulputate finibus eget eget felis. Sed elementum sit amet urna a posuere. Cras volutpat sagittis est, eget tempus leo interdum ac. Vestibulum accumsan dui at ornare rutrum. Phasellus orci lectus.</p>
</div>
<hr/>
              
            
!

CSS

              
                p{}
p:first-child{
  text-decoration: underline
}
p:last-child{
  --fullHeight: auto;
  height: var(--fullHeight);
  opacity: 0;
}
p.ready{
  height: 0;
  overflow: hidden;
  transition:all 1s ease-in
}
p.ready.open{
  height: var(--fullHeight);
  opacity: 1;
}
              
            
!

JS

              
                /* this is jQuery code  but simple in plain JS */

$(document).ready(function() {
  
  var p1 = $("p:first-child");
  var p2 = $("p:last-child");
  
  $(p2)[0].style.setProperty("--fullHeight",  $(p2).height() + "px");
  
  $(p2).addClass("ready");
  
  $(p1).on("click",function(e){
    
    $(p2).toggleClass("open");
    
  })
  
});
              
            
!
999px

Console