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

              
                <ul class="accordion">
  <li>
    <button class="accordion-control">Sentence One</button>
    <div class="accordion-panel">Sentence one content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Two</button>
    <div class="accordion-panel">Sentence two content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Three</button>
    <div class="accordion-panel">Sentence three content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Four</button>
    <div class="accordion-panel">Sentence four content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Five</button>
    <div class="accordion-panel">Sentence five content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Six</button>
    <div class="accordion-panel">Sentence six content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Seven</button>
    <div class="accordion-panel">Sentence seven content goes here...</div>
  </li>
  <li>
    <button class="accordion-control">Sentence Eight</button>
    <div class="accordion-panel">Sentence eight content goes here...</div>
  </li>
</ul>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');

body{
  background:#222;
  font-family:'Montserrat';
}

.accordion{
  width:90%;
  max-width:600px;
  list-style:none;
/*   border:1px solid red; */
  padding: 0;
  margin: 0 auto;
}

li{
  display: flex;
  flex-direction:column;
}

li + li{
/*   margin-top: 1em; */
  border-top:1px solid white;
}

.accordion-control{
  text-align: left;
  font-size:1.2rem;
  font-family:'Montserrat';
  background:#000;
  color:white;
  border:none;
  padding: 0.8em 1em;
  cursor:pointer;
}

.accordion-panel{
  padding: 1em;
  background:#444;
  color:#f4f4f4;
  display: none;
}
              
            
!

JS

              
                $('.accordion').on('click', '.accordion-control', function(e){
  e.preventDefault(); //prevent default action of a button 
  $(this) //get the element the user clicked on
    .next('.accordion-panel') //select the next accordion panel
    .not(':animated') //if it is not currently animating
    .slideToggle(); //use slideToggle to show or hide it
})
              
            
!
999px

Console