Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                <!-- 
Refs: 
- https://codepen.io/scottohara/pen/ybLMOm 
- from https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html
-->

<div class="disclosure">
  <button aria-expanded="false" data-disclosure-trigger>Show/hide content</button>
  <div class="disclosure__content">
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Neque, aliquid esse nisi ut atque velit!</p>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit neque non iste, similique repellat tenetur! Ab, officiis totam nulla rerum obcaecati quisquam non minus reiciendis? Ad reiciendis doloribus voluptatem suscipit!</p>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Aspernatur minus recusandae, dolores atque quae veniam debitis ex totam. Optio adipisci consequuntur ea totam et unde hic quod ratione, dicta animi.</p>
  </div>
</div>

<p>And here’s some content that comes after the disclosure widget.</p>
              
            
!

CSS

              
                .disclosure__content {
  /* because vis. respects `transition` */
  visibility: hidden;

  /* transitioning between max-height:0 
     to max-height:[something-more-than-sufficient]
     is best approach for a slide-down disclosure 
  */
  max-height: 0px;

  /* avoid visible content overflowing 
     the max-height during the transition 
  */
  overflow: hidden;

  /*   transition: all 0.2s ease-in-out; */
  transition: all 1s ease;

  /*   max-height: 0;
  overflow-y: hidden;
  transition: max-height 0.85s ease-in; */
}

[aria-expanded="true"] + .disclosure__content {
  visibility: visible;
  max-height: 200px;
}

:root {
  font-size: 110%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

input,
button {
  font-size: inherit;
  padding: 0.5em;
}

              
            
!

JS

              
                const triggerButton = document.querySelector("[data-disclosure-trigger]");
triggerButton.addEventListener("click", function () {
  let expanded = this.getAttribute("aria-expanded") === "true" || false;
  this.setAttribute("aria-expanded", !expanded);
});

              
            
!
999px

Console