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

              
                <h1>All CSS Accordion</h1>
<div class="accordion">
        <!-- span to target fix closing accordion -->
        <span class="target-fix" id="accordion"></span>
         
        <!-- First Accoridon Option -->
        <div>
            <!-- span to target fix accordion -->
            <span class="target-fix" id="accordion1"></span>
            
            <!-- Link to open accordion, hidden when open --> 
            <a href="#accordion1" id="open-accordion1" title="open">First Accordion</a>
            
            <!-- Link to close accordion, hidden when closed -->
            <a href="#accordion" id="close-accordion1" title="close">First Accordion</a> 
            
            <!-- Accorion content goes in this div -->
            <div class="accordion-content">
                <p>Accordion 1 Content</p>
            </div>
        </div>

        <!-- Second Accoridon Option -->
        <div>
            <span class="target-fix" id="accordion2"></span>
            <a href="#accordion2" id="open-accordion2" title="open">Second Accordion</a>
            <a href="#accordion" id="close-accordion2" title="close">Second Accordion</a>
            <div class="accordion-content">
                <p>Accordion 2 Content.</p>       
            </div>
        </div>

        <!-- Third Accoridon Option -->
        <div>
            <span class="target-fix" id="accordion3"></span>
            <a href="#accordion3" id="open-accordion3" title="open">Third Accordion</a>
            <a href="#accordion" id="close-accordion3" title="close">Third Accordion</a>
            <div class="accordion-content">
                <p>Accordion 3 Content</p>
            </div>
        </div>
    </div>

<div class="readme">
  <p>For multiple accordions on a single page, repeat process, but assign different id names. 
  <a href="https://codepen.io/pollardld/full/lthAF"> Multiple accordions example</a></p>
  
  <p>Beware use on Android 2.2 and 2.3. The default browser on these versions does some curious things.</p>
</div>
              
            
!

CSS

              
                body {
  background: #734f79;
  font-family: 'Flamenco', serif;
}

h1 {
  color: #fff;
  font-weight: normal;
  font-size: 2.5rem;
  text-align: center;
}

.readme {
  color: #fff;
  margin: 0 auto;
  width: 80%;
  
  a {
    color: #00a486;
  }
}

/*_________________  Accordion
________________________________________*/
.accordion {
  position: relative;
  margin: 60px auto;
  width: 80%;
}

[id*="open-accordion"], [id*="close-accordion"] {
  background: #00a486;
  border-bottom: 1px solid #fff;
  line-height: 40px;
  height: 40px;
  display: block;
  margin: 0 auto;
  position: relative;
  width: 99%;
}

[id*="close-accordion"] {
  display: none;
}

.accordion a {
  color: #fff;
  font-size: 1.25em;
  font-weight: normal;
  padding-left: 2%;
  text-decoration: none;
  text-shadow: none;
}

[id*="open-accordion"]:after, [id*="close-accordion"]:after {
  content: "";
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(255, 255, 255, 0.6);
  position: absolute;
  right: 5px;
  top: 15px;
  z-index: 999;
  transform: rotate(-90deg);
  -webkit-transform: rotate(-90deg);
}

.target-fix {
  display: block;
  top: 0;
  left: 0;
  position: fixed;
}

.accordion-content {
  background: #fff;
  height: 0;
  margin: -1px auto 0;
  padding: 0 2.5%;
  position: relative;
  overflow: hidden;
  width: 90%;
  transition: all 0.1s ease;
  -webkit-transition: all 0.1s ease;
  -moz-transition: all 0.1s ease;
}

.accordion span:target ~ .accordion-content {
  display: block;
  height: auto;
  padding-bottom: 25px;
  padding-top: 10px;
}

.accordion span:target ~ [id*="close-accordion"] {
  display: block;
}

.accordion span:target ~ [id*="open-accordion"] {
  display: none;
}

.accordion span:target ~ [id*="close-accordion"]:after {
  border-top: 10px solid #333;
  transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
}

              
            
!

JS

              
                
              
            
!
999px

Console