Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Bootstrap Elegant Accordion Widget</title> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500|Open+Sans"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <style> body { background: #e6e6e6; } .accordion .card { border: none; margin-bottom: 2px; border-radius: 0; box-shadow: 0 0 6px rgba(0,0,0,0.2); } .accordion .card .card-header { background: #6245dd; padding-top: 7px; padding-bottom: 7px; border-radius: 0; } .accordion .card-header h2 { color: #fff; font-size: 1rem; font-weight: 500; font-family: "Roboto", sans-serif; } .accordion img { width: 150px; } .accordion .card-header h2 span { float: left; margin-top: 10px; } .accordion .card-header .btn { font-weight: 500; } .accordion .card-header i { color: #fff; font-size: 1.3rem; margin: 0 6px 0 -10px; font-weight: bold; position: relative; top: 5px; } .accordion .card-header button:hover { color: #23384e; } .accordion .card-body { color: #666; } </style> <script> $(document).ready(function(){ // Add minus icon for collapse element which is open by default $(".collapse.show").each(function(){ $(this).siblings(".card-header").find(".btn i").html("remove"); }); // Toggle plus minus icon on show hide of collapse element $(".collapse").on('show.bs.collapse', function(){ $(this).parent().find(".card-header .btn i").html("remove"); }).on('hide.bs.collapse', function(){ $(this).parent().find(".card-header .btn i").html("add"); }); }); </script> </head> <body> <div class="container-lg"> <div class="row"> <div class="col-lg-8 mx-auto"> <div class="accordion mt-5" id="accordionExample"> <div class="card"> <div class="card-header" id="headingOne"> <h2 class="clearfix mb-0"> <a class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne"><i class="material-icons">add</i> Collapsible Group Item #1</a> </h2> </div> <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample"> <div class="card-body"> <div class="media"> <img src="/examples/images/media/home.png" class="mr-3" alt="Home"> <div class="media-body"> <h5 class="mt-0">Find Your New Home with a Click</h5> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante. Vestibulum id metus ac nisl bibendum scelerisque non non purus. Suspendisse varius nibh non aliquet sagittis. In tincidunt orci sit amet elementum vestibulum.</p> </div> </div> </div> </div> </div> <div class="card"> <div class="card-header" id="headingTwo"> <h2 class="mb-0"> <a class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"><i class="material-icons">add</i> Collapsible Group Item #2</a> </h2> </div> <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample"> <div class="card-body"> <div class="media"> <img src="/examples/images/media/search.png" class="mr-3" alt="Home"> <div class="media-body"> <h5 class="mt-0">Search Home in Your Area</h5> <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et.</p> </div> </div> </div> </div> </div> <div class="card"> <div class="card-header" id="headingThree"> <h2 class="mb-0"> <a class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree"><i class="material-icons">add</i> Collapsible Group Item #3</a> </h2> </div> <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample"> <div class="card-body"> <div class="media"> <img src="/examples/images/media/agent.png" class="mr-3" alt="Home"> <div class="media-body"> <h5 class="mt-0">Find a Real Estate Agent</h5> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante. Vestibulum id metus ac nisl bibendum scelerisque non non purus. Suspendisse varius nibh non aliquet sagittis. In tincidunt orci sit amet elementum vestibulum.</p> </div> </div> </div> </div> </div> <div class="card"> <div class="card-header" id="headingFour"> <h2 class="mb-0"> <a class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseFour" aria-expanded="false" aria-controls="collapseFour"><i class="material-icons">add</i> Collapsible Group Item #4</a> </h2> </div> <div id="collapseFour" class="collapse" aria-labelledby="headingFour" data-parent="#accordionExample"> <div class="card-body"> <div class="media"> <img src="/examples/images/media/location.png" class="mr-3" alt="Home"> <div class="media-body"> <h5 class="mt-0">Get Details of the Locality</h5> <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et.</p> </div> </div> </div> </div> </div> </div> </div> </div> </div> </body> </html>