JSFiddle - React, Tailwind, and code Playground

by jdmiller82

HTML

<div class="parent">
    <ul>
        <li>
            <span class="open-close">+</span>
            <h2>First</h2>
            <div class="content">
                <p>Jelly beans cookie ice cream danish wafer marzipan marshmallow applicake. Jelly-o candy canes bonbon. Fruitcake liquorice candy canes.
Applicake danish donut croissant icing wafer. Wafer liquorice bear claw macaroon marzipan. I love marzipan ice cream.</p>
            </div>
        </li>
        <li>
            <span class="open-close">+</span>
            <h2>Second</h2>
            <div class="content">
                <p>Jelly beans cookie ice cream danish wafer marzipan marshmallow applicake. Jelly-o candy canes bonbon. Fruitcake liquorice candy canes.
Applicake danish donut croissant icing wafer. Wafer liquorice bear claw macaroon marzipan. I love marzipan ice cream.</p>
            </div>
        </li>
        <li>
            <span class="open-close">+</span>
            <h2>Third</h2>
            <div class="content">
                <p>Jelly beans cookie ice cream danish wafer marzipan marshmallow applicake. Jelly-o candy canes bonbon. Fruitcake liquorice candy canes.
Applicake danish donut croissant icing wafer. Wafer liquorice bear claw macaroon marzipan. I love marzipan ice cream.</p>
            </div>
        </li>
    </ul>
</div>

CSS

.parent {
    display: block;
    margin: 0 auto;
    margin-top: 25px;
    padding: 0;
    width: 300px;
}

.parent ul {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
}

.parent ul li {
    position: relative;
    display: block;
    margin: 10px;
    padding: 10px;
    border: 1px solid #0088ff;
    border-radius: 0 5px 5px 0;
    background:#eaeaea;
    -webkit-transition:all 0.25s ease-in-out;
}

.parent ul li.on {
    background:#fff;
    border-radius:0 5px 5px 5px;
}

.parent ul li .open-close {
    position: absolute;
    top: 0;
    left: -36px;
    display: block;
    margin: -1px 0 0;
    padding: 0;
    width: 35px;
    height: 35px;
    line-height: 35px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 20px;
    color:#fff;
    background:#0088ff;
    border-top: 1px solid #0088ff;
    border-bottom: 1px solid #0088ff;
    border-left: 1px solid #0088ff;
    border-radius: 5px 0 0 5px;
}

.parent ul li h2 {
    display: block;
    margin: 0;
    padding: 0;
    height: 15px;
    line-height: 15px;
}

.parent ul li .content {
    display: none;
}

JavaScript

$('.parent ul li .open-close').toggle(function(){
    $(this)
        .html('-')
        .siblings('.content').stop(true, true).slideDown()
        .parent().addClass('on');
}, function(){
        $(this)
        .html('+')
        .siblings('.content').stop(true, true).slideUp()
        .parent().removeClass('on');
});