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 class="accordion-container">
  <div class="accordion-header">
    <i class="fa fa-angle-right"></i> Comment préparer un bon régime alimentaire ?
  </div>
  <div class="accordion-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eget tellus eget ex gravida fringilla. Pellentesque semper augue ac nunc viverra, sit amet aliquam odio hendrerit. Mauris tempus at risus.</div>
  <div class="accordion-header">
    <i class="fa fa-angle-right"></i> Pourquoi suivre un régime alimentaire ?
  </div>
  <div class="accordion-content">Duis scelerisque lectus ipsum, in laoreet diam feugiat id. Integer dapibus mauris justo, vel feugiat elit facilisis non. Maecenas ac eros eu arcu volutpat congue vel ut massa. Pellentesque habitant.</div>
  <div class="accordion-header">
    <i class="fa fa-angle-right"></i> Avec quoi préparer un bon régime alimentaire ?
  </div>
  <div class="accordion-content">Nulla a massa massa. Sed ultrices porta nisi, vel eleifend metus volutpat sed. Integer eget urna lorem. Etiam bibendum ante at neque dignissim efficitur. Phasellus iaculis, massa eu porta tincidunt.</div>
  <div class="accordion-header">
    <i class="fa fa-angle-right"></i> Où trouver des recettes pour un bon régime alimentaire ?
  </div>
  <div class="accordion-content">Phasellus faucibus suscipit est id lacinia. Suspendisse ultricies fermentum turpis, non lobortis sapien ultricies a. Integer sodales at sapien ut gravida. Sed pellentesque rhoncus arcu. Vestibulum maximus, felis dictum cursus.</div>
</div>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
              
            
!

CSS

              
                .accordion-header {
  background-color: #f2f2f2;
  color: #444;
  cursor: pointer;
  padding: 18px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 15px;
  transition: 0.4s;
}

.accordion-header:hover {
  background-color: #ddd;
}

.accordion-header i {
  margin-right: 10px;
}

.accordion-content {
  padding: 0 18px;
  background-color: white;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out;
}

@media (max-width: 767px) {
  .accordion-header {
    font-size: 18px;
  }
}

@media (min-width: 768px) {
  .accordion-header {
    font-size: 22px;
  }
}
              
            
!

JS

              
                 const headers = document.querySelectorAll(".accordion-header");
  headers.forEach(header => {
    header.addEventListener("click", function() {
      this.classList.toggle("active");
      const content = this.nextElementSibling;
		if (content.style.maxHeight) {
			content.style.maxHeight = null;
			this.querySelector("i").classList.remove("fa-angle-down");
			this.querySelector("i").classList.add("fa-angle-right");
		} else {
			content.style.maxHeight = content.scrollHeight + "px";
			this.querySelector("i").classList.remove("fa-angle-right");
			this.querySelector("i").classList.add("fa-angle-down");
		}
	});
});
              
            
!
999px

Console