How to create an accordion from scratch

This bootstrap snippet called "How to create an accordion from scratch" was created to help web designers,
front-end developers and back-end developer save time. Use it in your project and build your app faster,
You can also download the HTML, CSS, and JS code
tags: accordion,javascript,css,animated accordion,simple accordion,bootstrap accordion,bs4,bs4 accordion

This is the HTML code for this bootstrap snippet

Copy, paste, change, customize and run the following HTML code to get a result like the one shown in the preview tab

<div class="row">
    <div class="col-sm-12">
        <h4>How to create an accordion from scratch</h4>
    </div>
</div>

<div class="row">
    <div class="col-sm-6">
        <h6>Simple Accordion</h6>
        <button class="accordion"> Section 1</button>
        <div class="panel">
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </div>
        
         <button class="accordion"> Section 1</button>
        <div class="panel">
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </div>
        
         <button class="accordion"> Section 1</button>
        <div class="panel">
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </div>
    </div>
    
     <div class="col-sm-6">
        <h6>Animated Accordion (slide Down)</h6>
    </div>
</div>

This is the CSS code for this bootstrap snippet

Copy, paste, change, customize and run the following CSS code to get a result Like the one shown in the preview

body{margin-top:20px; background: #e6e6ff}

h4, h6{
    padding: 10px;    
}

/* Simple Accordion Block */
.accordion{
    margin: 10px;
    background: #3399ff;
    border: none;
    outline: none;
    width: 100%;
    transition: 0.4s;
    cursor: pointer;
    text-align: left;
}

.active, .accrodion:hover{
    color: #fff;
    background: #0066cc;
}

.panel{
    padding: 0px 10px;
}
/* Animated Accordion Block */
                                    

Information about this bootstrap snippet

Creator: Bettaibi Nidhal

Bootstrap version: 4.0.0-beta

Created: Jan 6th, 15:10

Views: 101