Simple accordion with toggle indicator

<!-- Start of Template --> 
<div class="hideContentWrap">
        <h4 class="hideContentHeader">Some Hidden Content</h4>
        <div class="hideContent">
        <img src=
        "http://www.wecreatemedia.com/wp-content/uploads/2014/07/34.jpg"></div>
 </div>
<!-- End of Template --> 
  
 <div class="hideContentWrap">
        <h4 class="hideContentHeader">More Hidden Content</h4>
        <div class="hideContent">
        <img src=
        "http://www.wecreatemedia.com/wp-content/uploads/2014/07/44.jpg"></div>
</div>

<div class="hideContentWrap">
        <h4 class="hideContentHeader">Props</h4>
        <div class="hideContent">
        <img src=
            "http://www.wecreatemedia.com/wp-content/uploads/2014/07/54.jpg">
        <p>Developement by Brian Bustos at <a href="http://www.umkc.edu/"
            target="_blank">UMKC</a><br>
            Background by <a href="https://subtlepatterns.com/" target=
            "_blank">Subtle Patterns</a><br>
            Photography by <a href="http://wecreatemedia.com" target=
            "_blank">WeCreate Media</a><br></p>
       </div>
</div>
$(document).ready(function() {
    $('.hideContentHeader').prepend('<span class="indicator">+</span> ');
    $('.hideContentHeader').click(function() {
        $(this).parent().find('.hideContent').slideToggle("slow");
    });
    $('.hideContentHeader').click(function() {
        $(this).toggleClass("active");
    });
    $('.hideContentHeader').click(function() {
        $(this).find('.indicator').toggleClass("rotate");
    });
});
/* ///////////////////////////////////////////////////////////////////// 
//  Not Important CSS
/////////////////////////////////////////////////////////////////////*/
body {
    background: url(https://subtlepatterns.com/patterns/black_lozenge.png) #000;
    padding-top: 100px;
}

h1 {
    color: #fff;
    text-align: center;
}

p {
    color: #fff;
    text-align: center;
    margin-bottom: 10px;
}

img {
    width: 100%;
    height: auto;
}

a {
    color: #fff;
}

/* ///////////////////////////////////////////////////////////////////// 
//  Important CSS
/////////////////////////////////////////////////////////////////////*/

.hideContentWrap {
    width: 600px;
    margin: 0 auto 10px;
}

.hideContentHeader {
    display: block;
    width: 90%;
    color: #fff;
    padding: 1%;
    margin: 0 auto;
    background: #FC4349;
    -webkit-transition: all .5s ease-in-out;
    -moz-transition: all .5s ease-in-out;
    -o-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out;
}

.hideContentHeader.active {
    color: #000;
    background: #6DBCDB;
}

h4.hideContentHeader:hover {
    cursor: pointer;
}

.hideContent {
    display: none;
    width: 92%;
    height: auto;
    margin: 0 auto;
}

.indicator {
    display: inline-block;
    padding: 5px;
    text-align: center;
    font-size: 20px;
    -webkit-transition: all .5s ease-in-out;
    -moz-transition: all .5s ease-in-out;
    -o-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out;
}

.indicator.rotate {
    transform: rotate(45deg);
    -ms-transform: rotate(45deg);
/* IE 9 */
    -webkit-transform: rotate(45deg);
/* Safari and Chrome */
}

Source: https://codepen.io/robotballoon/pen/FADHc

Leave a Reply

Your email address will not be published. Required fields are marked *