DropdownHTMLMenu.com

Bootstrap Accordion Example

Introduction

Website pages are the greatest area to feature a impressive concepts along with beautiful material in pretty cheap and simple manner and get them attainable for the whole world to discover and get used to. Will the material you've shared receive viewers's passion and attention-- this we may never ever discover till you really take it live for server. We have the ability to however think with a very serious probability of being right the effect of various components over the site visitor-- valuing possibly from our individual prior experience, the excellent practices described over the internet as well as most typically-- by the approach a webpage has an effect on ourselves during the time we're providing it a good shape during the design process. One thing is sure though-- big areas of plain text are very probable to bore the customer and push the customer elsewhere-- so what exactly to perform whenever we simply just wish to set this sort of much larger amount of text message-- such as terms , commonly asked questions, practical options of a material or a service which in turn need to be revealed and exact and so on. Well that is actually things that the style process in itself narrows down at the final-- getting working solutions-- and we really should find a solution working this one out-- feature the web content needed to have in intriguing and desirable way nevertheless it could be 3 pages plain text prolonged.

A great approach is covering the content within the so called Bootstrap Accordion Styles feature-- it presents us a great way to have just the explanations of our content clickable and present on webpage so normally all content is attainable at all times within a small area-- usually a single display with the purpose that the visitor may quickly click on what is necessary and have it widened to become acquainted with the detailed information. This solution is certainly as well instinctive and web format given that minimal acts have to be taken to keep on doing the job with the web page and in this way we make the site visitor evolved-- somewhat "push the switch and see the light flashing" thing.

The best way to put into action the Bootstrap Accordion Form:

Accordion example

Expand the default collapse activity to create an Bootstrap Accordion Table.

Accordion  model

Accordion  situation
Accordion example
<div id="accordion" role="tablist" aria-multiselectable="true">
  <div class="card">
    <div class="card-header" role="tab" id="headingOne">
      <h5 class="mb-0">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </a>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne">
      <div class="card-block">
        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. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" role="tab" id="headingTwo">
      <h5 class="mb-0">
        <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </a>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" role="tabpanel" aria-labelledby="headingTwo">
      <div class="card-block">
        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. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" role="tab" id="headingThree">
      <h5 class="mb-0">
        <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </a>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" role="tabpanel" aria-labelledby="headingThree">
      <div class="card-block">
        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. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>

Inside Bootstrap 4 we obtain the awesome instruments for creating an accordion prompt and simple applying the recently presented cards components adding just a couple of extra wrapper components. Listed here is the way: To start setting up an accordion we initially need an element to wrap the whole thing in-- develop a

<div>
element and give it an ID-- something like
id="MyAccordionWrapper"
or so attribute. ( click this)

Next step it is undoubtedly time to build the accordion sections-- put in a

.card
element, in it-- a
.card-header
to make the accordion title. Within the header-- incorporate an actual headline like
h1-- h6
with the
. card-title
class specified and within this kind of heading wrap an
<a>
element to definitely bring the heading of the panel. If you want to control the collapsing panel we are definitely about to build it should have
data-toggle = "collapse"
attribute, its goal needs to be the ID of the collapsing component we'll set up soon like
data-target = "long-text-1"
for example and lastly-- to make assured just one accordion feature continues to be extended at a time we should also bring in a
data-parent
attribute leading to the master wrapper for the accordion in our good example it really should be
data-parent = "MyAccordionWrapper"

One more situation

 Some other  model
<!DOCTYPE html>
<title>My Example</title>

<!-- Bootstrap 4 alpha CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/css/bootstrap.min.css" integrity="sha384-2hfp1SzUoho7/TsGGGDaFdsuuDL0LX2hnUp6VkX3CUQ2K4K+xjboZdsXyp4oUHZj" crossorigin="anonymous">
<style>
body 
padding-top: 1em;
 
</style>
<div class="container-fluid">
    
<div id="faq" role="tablist" aria-multiselectable="true">

<div class="card">
<div class="card-header" role="tab" id="questionOne">
<h5 class="card-title">
<a data-toggle="collapse" data-parent="#faq" href="#answerOne" aria-expanded="false" aria-controls="answerOne">
What if my boots are too big for my feet?
</a>
</h5>
</div>
<div id="answerOne" class="collapse" role="tabcard" aria-labelledby="questionOne">
<div class="card-block">
Stuff your boots with newspaper or tissue.
</div>
</div>
</div>

<div class="card">
<div class="card-header" role="tab" id="questionTwo">
<h5 class="card-title">
<a class="collapsed" data-toggle="collapse" data-parent="#faq" href="#answerTwo" aria-expanded="false" aria-controls="answerTwo">
Can I wear my boots inside?
</a>
</h5>
</div>
<div id="answerTwo" class="collapse" role="tabcard" aria-labelledby="questionTwo">
<div class="card-block">
No. Your mama should've told you about this.
</div>
</div>
</div>

<div class="card">
<div class="card-header" role="tab" id="questionThree">
<h5 class="card-title">
<a class="collapsed" data-toggle="collapse" data-parent="#faq" href="#answerThree" aria-expanded="true" aria-controls="answerThree">
What if my boots get slippery when wet?
</a>
</h5>
</div>
<div id="answerThree" class="collapse in" role="tabcard" aria-labelledby="questionThree">
<div class="card-block">
Keep your boots dry.
</div>
</div>
</div>

</div>

</div>
    
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script>

<!-- Tether -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script>

<!-- Bootstrap 4 Alpha JS -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/js/bootstrap.min.js" integrity="sha384-VjEeINv9OSwtWFLAtmc4JCtEJXXBub00gtSnszmspDLCtC0I4z4nqz7rEFbIZLLU" crossorigin="anonymous"></script>

<!-- Initialize Bootstrap functionality -->
<script>
// Initialize tooltip component
$(function () 
  $('[data-toggle="tooltip"]').tooltip()
)

// Initialize popover component
$(function () 
  $('[data-toggle="popover"]').popover()
)
</script>

Once this is accomplished it is undoubtedly moment for building the feature that will stay hidden and hold the actual information behind the headline. To execute this we'll wrap a

.card-block
in a
.collapse
element together with an ID attribute-- the similar ID we should install serving as a goal for the url in the
.card-title
from above-- for the example it really should be just like
id ="long-text-1"

As soon as this system has been set up you can insert either the plain text or else extra wrap your web content developing a little more complex design. ( read here)

Enhanced web content

Repeating the exercise from above you are able to bring in as many components to your accordion as you require to. Also in the case that you want a material feature to showcase extended-- appoint the

.in
or possibly
.show
classes to it baseding upon the Bootstrap 4 build version you are actually utilizing-- up to Alpha 5 the
.in
class goes and in Alpha 6 it becomes replaced by
.show

Conclusions

So generally that is really ways you can deliver an completely functioning and quite great looking accordion having the Bootstrap 4 framework. Do note it employs the card feature and cards do extend the whole zone provided by default. In this way incorporated together with the Bootstrap's grid column options you are able to quickly set up complex wonderful arrangements installing the whole thing inside an element with defined amount of columns width.

Review a couple of online video tutorials relating to Bootstrap Accordion

Linked topics:

Bootstrap accordion official documentation

Bootstrap acoordion  main  documents

How to make a Bootstrap v4 accordion collapse when clicking the whole header div?

How to make a Bootstrap v4 accordion collapse when clicking the whole header div?

GitHub:Collapse Accordion is still using Panels

GitHub:Collapse Accordion is still using Panels