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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="menu-collapse">

				<button class="accordion">New Students</button>
				<div class="panel">
				  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Praesentium dolorem, eos numquam quod. Doloribus minima excepturi cupiditate, laudantium est, nobis magni, sed illum labore nemo animi sunt tempora culpa ab. Dolor laudantium quia quibusdam ducimus, dicta maxime omnis repellendus distinctio tenetur hic quaerat debitis, sapiente quam id minima molestias rem.</p>
				</div>

				<button class="accordion">Readmissions</button>
				<div class="panel">
				  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dicta libero, soluta obcaecati provident voluptates sint molestias esse non, perspiciatis similique architecto repellat tempore molestiae dolores voluptate eos. Facilis fugiat, magnam molestiae aut, quae nobis ducimus animi quibusdam laborum voluptatibus labore.</p>
				</div>

				<button class="accordion">Transfers</button>
				<div class="panel">
				  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet consectetur non cumque facilis vel omnis, cupiditate? Deleniti vel culpa sint quibusdam dolore consequuntur atque est rerum architecto. Ratione mollitia consequuntur, nostrum architecto labore culpa nemo quasi deleniti, corporis enim eveniet libero quae aut velit nihil quia neque, optio praesentium asperiores esse laborum. Ab quis, rerum, autem dolor quam dolorem. Neque.</p>
				</div>
				<button class="accordion">Program Change</button>
				<div class="panel">
				  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet consectetur non cumque facilis vel omnis, cupiditate? Deleniti vel culpa sint quibusdam dolore consequuntur atque est rerum architecto. Ratione mollitia consequuntur, nostrum architecto labore culpa nemo quasi deleniti, corporis enim eveniet libero quae aut velit nihil quia neque, optio praesentium asperiores esse laborum. Ab quis, rerum, autem dolor quam dolorem. Neque.</p>
				</div>
				<button class="accordion">Professionals</button>
				<div class="panel">
				  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet consectetur non cumque facilis vel omnis, cupiditate? Deleniti vel culpa sint quibusdam dolore consequuntur atque est rerum architecto. Ratione mollitia consequuntur, nostrum architecto labore culpa nemo quasi deleniti, corporis enim eveniet libero quae aut velit nihil quia neque, optio praesentium asperiores esse laborum. Ab quis, rerum, autem dolor quam dolorem. Neque.</p>
				</div>

			</div>

              
            
!

CSS

              
                /* menu collapse */

.menu-collapse{
	margin: 60px 0;
}

button.accordion {
	background: none;
	border: none;
	border-top: 1px solid #e2e2e2;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    text-align: left;
    outline: none;
    font-size: 20px;
    transition: 0.4s;
    font-family: 'Montserrat', sans-serif;
}

button.accordion.active, button.accordion:hover {
    background-color: #f0f0f0;
}

button.accordion:after {
    content: '\02795';
    font-size: 14px;
    color: #777;
    float: right;
    margin-left: 5px;
}

button.accordion.active:after {
    content: "\2796";
}

div.panel {
    padding: 0 18px;
    max-height: 0;
    overflow: hidden;
    transition: 0.4s ease-in-out;
    opacity: 0;
}

div.panel.hide{
	overflow: hidden;
	opacity: 0;
}

div.panel.show {
    opacity: 1;
    max-height: 500px;
}
              
            
!

JS

              
                // var acc = document.getElementsByClassName("accordion");
// for (i = 0; i < acc.length; i++) {
//    acc[i].onclick = function(){
//        this.classList.toggle("active");
//        this.nextElementSibling.classList.toggle("show");
//  	}

// };


var acc = document.getElementsByClassName("accordion");
for (i = 0; i < acc.length; i++) {
  acc[i].onclick = function(){

    // obtener el número de acordeones abiertos
    var numActive = document.querySelectorAll(".accordion.active");
    // si hay alguno abierto Y no es el que se ha pulsado
    if (numActive.length == 1 && numActive[0] != this) {
      // lo cerramos
      numActive[0].classList.toggle("active");
      numActive[0].nextElementSibling.classList.toggle("show");
    }

    // esta parte sigue sin cambiar
    this.classList.toggle("active");
    this.nextElementSibling.classList.toggle("show");

  }

};


              
            
!
999px

Console