cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <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>
            
          
!
            
              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);
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console