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 class="title"><strong>No Boostrap</strong> | jQuery Animated Accordions</h1>

<div class="container">
  
  <div id="accordion-1">
    <div class="head">
      <h2>1. Simple Accordion</h2>
      <i class="fas fa-angle-down arrow"></i>
    </div>
    <div class="content">
      <p>An accordion is used to show and hide content. It can be usually found in Q & A section.</p>
    </div>
  </div>
  
  <br>
  
  <div id="accordion-2">
    <div class="head">
      <h2>2. Tree-like Multiple Accordion</h2>
      <i class="fas fa-angle-down arrow"></i>
    </div>
    <div class="content">
      <p>Such accordion emphasizes hierarchy.</p>
    </div>
    <div class="content">
      <p>Such accordion emphasizes hierarchy.</p>
    </div>
    <div class="content">
      <p>Such accordion emphasizes hierarchy.</p>
    </div>
  </div>
  
  <br>
  
  <div id="accordion-3">
    <div class="head">
      <h2>3. Chatbox-like Accordion</h2>
      <i class="arrow"></i>
    </div>
    <div class="content">
      <p>An accordion is used to show and hide content. It can be usually found in Q & A section.</p>
    </div>
  </div>
  
</div>

<p class="remarks">Created By <a href="https://codepen.io/nikoso">Niko</a></p>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:300,900);

body{
  font-family: Lato;
  background: #FFF;
  height: 1000px;
}

h1.title{
  text-align: center;
  font-size: 40px;
  color: #282828;
  font-weight: 300;
  margin-bottom: 2.5rem;
}

b{
  color: #FFFFFF;
  font-size: 55px;
}

p.remarks, a{
  text-align: center;
  margin-top: 100px;
  color: #FFFFFF;
}

.container{
  width: 100%;
  max-width: 650px;
  min-width: 300px;
  margin: 0 auto;
  padding: 0 5vh;
}

/* accordion-1 */
#accordion-1{
  position: relative;
}

#accordion-1 .head{
  background-color: #6e2fdf;
  color: #FFFFFF;
  padding: 20px 30px;
  cursor: pointer;
  transition: 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#accordion-1 .arrow{
  color: #FFFFFF;
  font-size: 60px;
  transition: 0.25s ease;
  opacity: 0.3;
  transform: rotate(-90deg);
}

#accordion-1 .head:hover .arrow{
  opacity: 1;
}

#accordion-1 .head:hover, #accordion-1 .active{
  background-color: #3e0891;
}

#accordion-1 .arrow-animate{
  transform: rotate(-180deg);
  opacity: 1;
}

#accordion-1 .content{
  background-color: #F3EDFF;
  display: none;
  padding: 20px 30px;
  color: #222222;
}

/* accordion-2 */
#accordion-2{
  position: relative;
}

#accordion-2 .head{
  background-color: #6e2fdf;
  color: #FFFFFF;
  padding: 1rem 2rem;
  cursor: pointer;
  transition: 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#accordion-2 .arrow{
  color: #FFFFFF;
  font-size: 60px;
  transition: 0.25s ease;
  opacity: 0.3;
  transform: rotate(-90deg);
}

#accordion-2 .head:hover .arrow{
  opacity: 1;
}

#accordion-2 .arrow-animate{
  transform: rotate(-180deg);
  opacity: 1;
}

#accordion-2 .content{
  background-color: #F3EDFF;
  display: none;
  padding: 1rem 4rem;
  color: #222222;
  position: relative;
}

#accordion-2 .content:nth-child(odd){
  background-color: #EAE0FB;
}

#accordion-2 .content::before{
  content: "";
  width: 4px;
  position: absolute;
  background-color: #3e0891;
  top: 0;
  left: 2.4rem;
  height: 100%;
  animation: vertical-fade-in forwards 1s;
  animation-delay; 200ms;
}

@keyframes vertical-fade-in{
  from{
    opacity: 0;
  }
  to{
    opacity: 1;
  }
}

#accordion-2 .content::after{
  content: "";
  height: 4px;
  position: absolute;
  background-color: #3e0891;
  top: 50%;
  left: 2.4rem;
  animation: horizontal-fade-in forwards 1s;
  animation-delay: 300ms;
}

@keyframes horizontal-fade-in{
  from{
    opacity: 0;
    width: 0;
  }
  to{
    opacity: 1;
    width: 1rem;
  }
}

#accordion-2 .head:hover, #accordion-2 .active{
  background-color: #3e0891; 
}

/* accordion-3 */
#accordion-3{
  position: relative;
}

#accordion-3 .head{
  background-color: #6e2fdf;
  color: #FFFFFF;
  padding: 20px 30px;
  cursor: pointer;
  transition: 0.25s;
}

#accordion-3 .arrow{
  content:'';
  position: absolute;
  right: 0;
  right: 30px;
  top: 65px;
  opacity: 1;
  border-left: 35px solid transparent;
  border-right: 35px solid transparent;
  border-top: 40px solid #6e2fdf;
  transition: 0.3s ease;
  z-index: 2;
}

#accordion-3 .head:hover .arrow, #accordion-3 .arrow-animate{
  border-top: 40px solid #3e0891;
  transform: translateY(40px);
}

#accordion-3 .content{
  background-color: #F3EDFF;
  display: none;
  padding: 30px;
  color: #222222;
}

#accordion-3 .head:hover, #accordion-3 .active{
  background-color: #3e0891; 
}


              
            
!

JS

              
                $('.head').click(function(){
  $(this).toggleClass('active');
  $(this).parent().find('.arrow').toggleClass('arrow-animate');
  $(this).parent().find('.content').slideToggle(280);
});

// icon from Font Awesome was used in accordion-1
              
            
!
999px

Console