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

              
                <div>
    <h4>Accordian</h4>
    <div class="accordian">  
        <ul> 
            <li> 
                <h3>
                    <span class="arrow"></span> Fugit Diamlorem
                </h3>
                <ul>
                    <li>
                        <p>Fugit diamlorem. Aut magni, laboriosam congue lobortis exercitation, repellat, dolor, consequatur, nobis sociosqu, culpa voluptas consectetur excepturi aptent.</p>
                        <p>Perferendis amet! Dis, ullamcorper proin aspernatur! Posuere consequat. Senectus orci turpis augue laoreet corrupti possimus, fugiat molestiae elit, ipsa sapien euismod quod! Diamlorem felis. Enim. Quibusdam rerum ipsa dis incididunt.
                            Minus nostra.</p>
                    </li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Perferendis
                </h3>
                <ul>
                    <li>
                        <p>Fugit diamlorem. Aut magni, laboriosam congue lobortis exercitation, repellat, dolor, consequatur, nobis sociosqu, culpa voluptas consectetur excepturi aptent.</p>
                    </li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Ullamcorper Proin Aspernatur
                </h3>
                <ul>
                    <li>
                        <p>Fugit diamlorem. Aut magni, laboriosam congue lobortis exercitation, repellat, dolor, consequatur, nobis sociosqu, culpa voluptas consectetur excepturi aptent.</p>
                        <p>Perferendis amet! Dis, ullamcorper proin aspernatur! Posuere consequat. Senectus orci turpis augue laoreet corrupti possimus, fugiat molestiae elit, ipsa sapien euismod quod! Diamlorem felis. Enim. Quibusdam rerum ipsa dis incididunt.
                            Minus nostra.</p>
                    </li>
                </ul>
            </li>
        </ul>
    </div> 
</div>

<div>
    <h4>Sidebar/Nav</h4>
    <div class="accordian sidebarNav">
        <ul>
            <li>
                <h3>
                    <span class="arrow"></span> Fugit Diamlorem
                </h3>
                <ul>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Perferendis
                </h3>
                <ul>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Ulamcorp Aspernatur
                </h3>
                <ul>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Molestiae Elit
                </h3>
                <ul>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                    <li><a href="/">I am a link to nowhere.</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>

<div>
    <h4>Accordian - starting open</h4>
    <div class="accordian">
        <ul>
            <!-- Add 'active' class to start with a drawer already open: <li class="active"> -->
            <li class="active">
                <h3>
                    <span class="arrow"></span> Fugit Diamlorem
                </h3>
                <ul>
                    <li>
                        <p>Fugit diamlorem. Aut magni, laboriosam congue lobortis exercitation, repellat, dolor, consequatur, nobis sociosqu, culpa voluptas consectetur excepturi aptent.</p>
                        <p>Perferendis amet! Dis, ullamcorper proin aspernatur! Posuere consequat. Senectus orci turpis augue laoreet corrupti possimus, fugiat molestiae elit, ipsa sapien euismod quod! Diamlorem felis. Enim. Quibusdam rerum ipsa dis incididunt.
                            Minus nostra.</p>
                    </li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Perferendis
                </h3>
                <ul>
                    <li>
                        <p>Fugit diamlorem. Aut magni, laboriosam congue lobortis exercitation, repellat, dolor, consequatur, nobis sociosqu, culpa voluptas consectetur excepturi aptent.</p>
                    </li>
                </ul>
            </li>
            <li>
                <h3>
                    <span class="arrow"></span> Perferendis
                </h3>
                <ul>
                    <li>
                        <p>Fugit diamlorem. Aut magni, laboriosam congue lobortis exercitation, repellat, dolor, consequatur, nobis sociosqu, culpa voluptas consectetur excepturi aptent.</p>
                        <p>Perferendis amet! Dis, ullamcorper proin aspernatur! Posuere consequat. Senectus orci turpis augue laoreet corrupti possimus, fugiat molestiae elit, ipsa sapien euismod quod! Diamlorem felis. Enim. Quibusdam rerum ipsa dis incididunt.
                            Minus nostra.</p>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</div>
              
            
!

CSS

              
                :root {
    --dark-gray: #444444;
    --light-gray: #c9c9c5;
}

.accordian {
    max-width: 600px;
    width: 100%;
    color: #b9b9b9;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-weight: 100;
    letter-spacing: 0.035em;
    font-size: 14px;
    margin: 0 auto;
    ul > li {
        margin-bottom: 8px;
        &:first-child h3 {
            border-top: 1px solid rgba(0, 0, 0, 0.1);
        }
    }
    h3 {
        cursor: pointer;
        background-color: #f7f9f9;
        padding: 1.2rem 1rem 1rem 1.2rem;
        margin: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.07);
        display: block;
        font-weight: 100;
        letter-spacing: 0.035em;
        position: relative;
        font-size: 18px;
        transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
        border-radius: 3px;
        &:hover,
        &.closed {
            color: var(--dark-gray);
            background-color: #fff;
        }
        &:hover .arrow {
            border-top: 2px solid var(--dark-gray);
            border-right: 2px solid var(--dark-gray);
        }
    }
    ul ul {
        display: none;
        height: 100%;
        margin-bottom: -7px;
        li {
            background-color: #fff;
            padding: 1rem 1.8rem;
            color: var(--dark-gray);
            box-shadow: none;
            border-left: 1px solid #dfdfdf;
            border-right: 1px solid #dfdfdf;
            border-bottom: 1px solid #dfdfdf;
            p {
                opacity: 0;
                transition: all 0.5s;
                transform: translatey(-20px);
            }
        }
        &.open p {
            opacity: 1;
            transform: translatey(0px);
        }
    }
    .arrow {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-top: 2px solid var(--light-gray);
        border-right: 2px solid var(--light-gray);
        transform: rotate(135deg);
        transform-origin: center;
        float: right;
        margin-right: 8px;
        transition: transform 600ms cubic-bezier(0.175, 0.885, 0.32, 1);
        &.closed {
            margin-top: 4px;
            transform: rotate(-45deg);
            border-top: 2px solid var(--dark-gray);
            border-right: 2px solid var(--dark-gray);
        }
    }
}

// Sidebar specific
.sidebarNav {
    max-width: 300px;
    border: 1px solid #9999993b;
    h3 {
        border-radius: 0;
        box-shadow: none;
        background: none;
        margin-bottom: 0;
        &:hover,
        &.closed {
            background: none;
        }
    }
    ul > li {
        margin: 0;
    }
    ul ul li {
        padding: 0;
        background: none;
        border: 0;
        a {
            color: var(--darkgray);
            padding: 1rem 0 1rem 3em;
            display: block;
            text-decoration: none;
            &:hover {
                text-decoration: underline;
            }
        }
    } 
}


///////////////////////////////////////////////////////////////
// Layout stuff

html,
body {
    height: 100%; 
}

body {
    background-color: #eaf0f2;
    font-family: 'Josefin Sans', sans-serif;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    padding: 100px 100px 800px;
    > div {
        flex: 1 1 600px;
        margin-bottom: 100px;
    }
}

ul,
ol {
    margin: 0;
    padding: 0;
}

li {
    list-style: none;
    padding: 0;
}

p {
    line-height: 1.8em;
    margin-bottom: 20px;
}

h4 {
    text-align: center;
    margin: 20px 20px 50px;
    color: orange;
    font-size: 2em;
}

              
            
!

JS

              
                
$(function() { 
  $('.accordian li').on('click', function() {
    if ($(this).find('ul').hasClass('open')) {
      $('ul.open').slideToggle().removeClass('open');
      $('.accordian h3 span').removeClass('closed');
      $('.accordian h3').removeClass('closed');
    } else {
      $('ul.open').slideToggle().removeClass('open');
      $(this).find('ul').slideToggle().addClass('open');
      $('.accordian h3, .accordian h3 span').removeClass('closed');
      $(this).find('h3, h3 span').addClass('closed')
    }
  });
  // Active class starts one open
  $('.accordian li.active ul').slideDown().addClass('open');
});

              
            
!
999px

Console