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

              
                <h1>jQuery accordion</h1>

<ul class="accordion">
	<li class="accordion-item is-active">
		<h3 class="accordion-thumb">Lorem ipsum</h3>
		<p class="accordion-panel">
			Lorem ipsum dolor sit amet, consectetur adipisicing
			elit. Placeat, quibusdam! Voluptate nobis, beatae
			tempora praesentium, illum quis illo, maiores quod
			similique placeat, saepe mollitia dolor officiis
			aspernatur deleniti debitis commodi!
		</p>
	</li>
	
	<li class="accordion-item">
		<h3 class="accordion-thumb">Dolor sit amet</h3>
		<p class="accordion-panel">
			Lorem ipsum dolor sit amet, consectetur adipisicing
			elit. Reprehenderit quos, accusamus! Enim labore totam
			dicta quibusdam? Eveniet quis asperiores reprehenderit
			eaque atque in iure voluptate, explicabo, placeat, id
			earum architecto!
		</p>
	</li>
	
	<li class="accordion-item">
		<h3 class="accordion-thumb">Consectetur adipisicing elit</h3>
		<p class="accordion-panel">
			Lorem ipsum dolor sit amet, consectetur adipisicing
			elit. Reprehenderit quos, accusamus! Enim labore
			totam dicta quibusdam? Eveniet quis asperiores
			reprehenderit eaque atque in iure voluptate,
			explicabo, placeat, id earum architecto!
		</p>
	</li>
</ul>
              
            
!

CSS

              
                .accordion {
	margin: 1rem 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid #e5e5e5;
}

.accordion-item {
	border-bottom: 1px solid #e5e5e5;
}

/* Thumb */
.accordion-thumb {
	margin: 0;
	padding: .8rem 0;
	cursor: pointer;
	font-weight: normal;
	
	// Chevron
	&::before {
		content: '';
		display: inline-block;
		height: 7px;
		width: 7px;
		margin-right: 1rem;
		margin-left: .5rem;
		vertical-align: middle;
		border-right: 1px solid;
		border-bottom: 1px solid;
		transform: rotate(-45deg);
		transition: transform .2s ease-out;
	}
}

/* Panel */
.accordion-panel {
	margin: 0;
	padding-bottom: .8rem;
	display: none;
}

/* Active */
.accordion-item.is-active {
	.accordion-thumb::before {
		transform: rotate(45deg);
	}
}

/* General page styling */
html {
	font-family: sans-serif;
	font-size: 14px;
	color: #444;
}

body {
	line-height: 1.5;
	margin: 0 auto;
	max-width: 500px;
}

h1 {
	font-family: serif;
	margin-top: 15%;
}
              
            
!

JS

              
                $(function() {
	// (Optional) Active an item if it has the class "is-active"	
	$(".accordion > .accordion-item.is-active").children(".accordion-panel").slideDown();
	
	$(".accordion > .accordion-item").click(function() {
		// Cancel the siblings
		$(this).siblings(".accordion-item").removeClass("is-active").children(".accordion-panel").slideUp();
		// Toggle the item
		$(this).toggleClass("is-active").children(".accordion-panel").slideToggle("ease-out");
	});
});
              
            
!
999px

Console