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

              
                <!--* Icons -->
<!-- Google Icons -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" />

<!--* second accordion example -->
<section class="accordion-examples">
  <h2 class="accordion-examples__heading">Accordion 2</h2>

  <div class="accordion2-wrapper">
    <!-- first accordion -->
    <div class="accordion2-card">
      <h3 class="accordion2-card__header">
        Header 1
        <span class="icons material-icons-outlined">
          add_circle_outline
        </span>
      </h3>
      <p class="accordion2-card__body">
        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Et
        neque, velit quasi quos quia nulla omnis! Similique dolorum,
        veniam facilis aliquam est fuga aperiam voluptatibus, sapiente
        atque vitae quia accusamus.
      </p>
    </div>

    <!-- second accordion -->
    <div class="accordion2-card">
      <h3 class="accordion2-card__header">
        Header 2
        <span class="icons material-icons-outlined">
          add_circle_outline
        </span>
      </h3>
      <p class="accordion2-card__body">
        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Et
        neque, velit quasi quos quia nulla omnis! Similique dolorum,
        veniam facilis aliquam est fuga aperiam voluptatibus, sapiente
        atque vitae quia accusamus.
      </p>
    </div>

    <!-- third accordion -->
    <div class="accordion2-card">
      <h3 class="accordion2-card__header">
        Header 3
        <span class="icons material-icons-outlined">
          add_circle_outline
        </span>
      </h3>
      <p class="accordion2-card__body">
        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Et
        neque, velit quasi quos quia nulla omnis! Similique dolorum,
        veniam facilis aliquam est fuga aperiam voluptatibus, sapiente
        atque vitae quia accusamus.
      </p>
    </div>
  </div>
</section>
              
            
!

CSS

              
                /* ! project styles */
.accordion-examples__heading {
  text-align: center;
}
/* accordion wrapper */
.accordion2-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* accordion card */
.accordion2-card {
  width: 280px;
  border: double goldenrod;
  background-color: white;
}

/* accordion header */
.accordion2-card__header {
  color: #202020;
  position: relative;
  padding: 10px;
  margin-bottom: 0;
}

/* icons */
.icons {
  position: absolute;
  right: 10px;
  color: goldenrod;
  transform: rotate(0deg);
  transition: transform 300ms, color 300ms;
}

/* accordion body */
.accordion2-card__body {
  border-top: solid 1px goldenrod;
  padding: 10px;
  color: #3d3b3b;
  display: none;
}

/* javascript css classes to be added and removed */
.toggleIcon {
  transform: rotate(45deg);
  color: hsl(0, 70%, 50%);
}

.active {
  display: block;
}

              
            
!

JS

              
                // * Function for accordion 2
// variables
const accordion2BtnToggle = document.querySelectorAll(
  ".accordion2-card__header"
);

// adding event listener to the accordion2 toggle button
for (i of accordion2BtnToggle) {
  i.addEventListener("click", accordion2ToggleFunction);
}

// here the other bodies do not automatically close then the current one is open
function accordion2ToggleFunction() {
  this.nextElementSibling.classList.toggle("active");
  this.children[0].classList.toggle("toggleIcon");
}

              
            
!
999px

Console