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

              
                <link href='https://fonts.googleapis.com/css?family=Old+Standard+TT' rel='stylesheet' type='text/css'>

<div class="wrap">
	
    <h1 class="heading">The NO-JS Accordion Experiment Using :checked, general sibling, and CSS3 transitions</h1>
	
    <ul class="accordion js-accordion">
        <li class="accordion-item">
            <input class="accordion-item-input" type="checkbox" name="accordion" id="item1" />
            <label for="item1" class="accordion-item-hd js-accordionTrigger">Some Sort of heading for an example.<span class="accordion-item-hd-cta">&#9650;</span></label>
            <div class="accordion-item-bd">
				<div class="accordion-item-bd-wrap">
					Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex consequuntur architecto maxime, saepe repudiandae quidem quisquam aliquam cumque possimus inventore, deserunt nostrum, explicabo modi voluptatibus sed, labore quaerat. Accusamus, officiis.
				</div>
            </div>
        </li>
        <li class="accordion-item">
            <input class="accordion-item-input" type="checkbox" name="accordion" id="item2" />
            <label for="item2" class="accordion-item-hd js-accordionTrigger">Some Sort of heading for an example.<span class="accordion-item-hd-cta">&#9650;</span></label>
            <div class="accordion-item-bd"><div class="accordion-item-bd-wrap">
					Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex consequuntur architecto maxime, saepe repudiandae quidem quisquam aliquam cumque possimus inventore, deserunt nostrum, explicabo modi voluptatibus sed, labore quaerat. Accusamus, officiis.
				</div>
            </div>
        </li>
    </ul>
	
    <h2>Features</h2>
	
    <ul>
        <li>No JS</li>
        <li>Clean and Responsive</li>
        <li>Animation doesn't need a set height</li>
        <li>Switching between radio or checkbox input type determines whether one or many can be open at the same time</li>
        <li>Accessible and screen reader friendly. (Doesn't use display: none;)</li>
        <li>Progressively works in IE9, but without the animation (need to test this).</li>
        <li>Large clickable trigger region: The entire head section triggers the expansion of the body.</li>
        <li>Super vanilla and can easily be customized.</li>
    </ul>
</div>
              
            
!

CSS

              
                // Local SASS Variables
$accordion-CTA_HEIGHT: 12px;
$accordion-CTA_WIDTH: 30px;
$accordion-SPACING_UNIT: 15px;

body { // Some styles for presentation.
  font-family: "Old standard TT";
background: linear-gradient(to right, rgba(76,76,76,1) 0%, rgba(71,71,71,1) 0%, rgba(89,89,89,1) 0%, rgba(102,102,102,1) 0%, rgba(45,54,110,1) 78%, rgba(45,54,110,1) 100%);
	color: white;
	text-shadow: 2px 2px black;
}

.wrap {
	max-width: 600px; // Change this to experiment with it's responsiveness.
	margin: 0 auto;
}

.heading {
	text-align: center;
	text-shadow: 2px 4px black
}

// Start Main Styles
.accordion {
 border: 1px solid white;
  padding: 0 10px;
	margin: 0 auto;
  list-style: none outside;
}

.accordion > * + * {
  border-top: 1px solid white;
}

.accordion-item-hd {
  display: block;
  // Large clickable trigger is a plus
  padding: $accordion-SPACING_UNIT $accordion-CTA_WIDTH $accordion-SPACING_UNIT 0;
  position: relative;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
}

.accordion-item-bd-wrap {
	padding-top: $accordion-SPACING_UNIT;
  margin-bottom: $accordion-SPACING_UNIT;
}

.accordion-item-input:checked ~ .accordion-item-bd {
  max-height: 600px; //It'll animate to it's natural height, but this needs to be something to accomodate all potential heights.
  transition: max-height .5s ease-in;
}

.accordion-item-input:checked ~ .accordion-item-hd > .accordion-item-hd-cta {
  transform: rotate(0);
}

.accordion-item-hd-cta {
  display: block;
  width: $accordion-CTA_WIDTH;
  position: absolute;
  top: calc(50% - #{$accordion-CTA_HEIGHT / 2} ); /*minus half font-size*/
  right: 0;
  pointer-events: none;
  transition: transform .5s ease;
  transform: rotate(-180deg);
  text-align: center;
  font-size: $accordion-CTA_HEIGHT;
  line-height: 1;
}

.accordion-item-bd {
  max-height: 0; // Closed Default: Animating max-height allows no set heights if the range is big enough.
  margin-bottom: 0;
  overflow: hidden;
  transition: max-height .3s ease-out,;
}

.accordion-item-input { //Visually hiding the form element being leveraged for it's :checked state/class.
	clip: rect(0 0 0 0);
	width: 1px;
	height: 1px;
	margin: -1;
	overflow: hidden;
	position: absolute;
	left: -9999px;
}
              
            
!

JS

              
                // Aint nothin to see here folks.
              
            
!
999px

Console