Skip to content

Instantly share code, notes, and snippets.

@SirmaXX
Created November 17, 2023 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirmaXX/3dc2f14ee6aa83355877448561c92594 to your computer and use it in GitHub Desktop.
Save SirmaXX/3dc2f14ee6aa83355877448561c92594 to your computer and use it in GitHub Desktop.
boostrap 5 accordion change icon
<div class="row gx-5">
<div class="col-xl-8">
<!-- FAQ Accordion 1-->
<h2 class="fw-bolder mb-3">Account &amp; Billing</h2>
<div class="accordion mb-5" id="accordionExample">
<div class="accordion-item">
<h3 class="accordion-header" id="headingOne"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">Accordion Item #1</button></h3>
<div class="accordion-collapse collapse show" id="collapseOne" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
<div class="accordion-body">
<strong>This is the first item's accordion body.</strong>
It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
<code>.accordion-body</code>
, though the transition does limit overflow.
</div>
</div>
</div>
<div class="accordion-item">
<h3 class="accordion-header" id="headingTwo"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">Accordion Item #2</button></h3>
<div class="accordion-collapse collapse" id="collapseTwo" aria-labelledby="headingTwo" data-bs-parent="#accordionExample">
<div class="accordion-body">
<strong>This is the second item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
<code>.accordion-body</code>
, though the transition does limit overflow.
</div>
</div>
</div>
<div class="accordion-item">
<h3 class="accordion-header" id="headingThree"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">Accordion Item #3</button></h3>
<div class="accordion-collapse collapse" id="collapseThree" aria-labelledby="headingThree" data-bs-parent="#accordionExample">
<div class="accordion-body">
<strong>This is the third item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
<code>.accordion-body</code>
, though the transition does limit overflow.
</div>
</div>
</div>
</div>
<!-- FAQ Accordion 2-->
<h2 class="fw-bolder mb-3">Website Issues</h2>
<div class="accordion mb-5 mb-xl-0" id="accordionExample2">
<div class="accordion-item">
<h3 class="accordion-header" id="headingOne"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne2" aria-expanded="true" aria-controls="collapseOne2">Accordion Item #1</button></h3>
<div class="accordion-collapse collapse show" id="collapseOne2" aria-labelledby="headingOne" data-bs-parent="#accordionExample2">
<div class="accordion-body">
<strong>This is the first item's accordion body.</strong>
It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
<code>.accordion-body</code>
, though the transition does limit overflow.
</div>
</div>
</div>
<div class="accordion-item">
<h3 class="accordion-header" id="headingTwo"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo2" aria-expanded="false" aria-controls="collapseTwo2">Accordion Item #2</button></h3>
<div class="accordion-collapse collapse" id="collapseTwo2" aria-labelledby="headingTwo" data-bs-parent="#accordionExample2">
<div class="accordion-body">
<strong>This is the second item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
<code>.accordion-body</code>
, though the transition does limit overflow.
</div>
</div>
</div>
<div class="accordion-item">
<h3 class="accordion-header" id="headingThree"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree2" aria-expanded="false" aria-controls="collapseThree2">Accordion Item #3</button></h3>
<div class="accordion-collapse collapse" id="collapseThree2" aria-labelledby="headingThree" data-bs-parent="#accordionExample2">
<div class="accordion-body">
<strong>This is the third item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
<code>.accordion-body</code>
, though the transition does limit overflow.
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4">
<div class="card border-0 bg-light mt-xl-5">
<div class="card-body p-4 py-lg-5">
<div class="d-flex align-items-center justify-content-center">
<div class="text-center">
<div class="h6 fw-bolder">Have more questions?</div>
<p class="text-muted mb-4">
Contact us at
<br />
<a href="#!">info@alphaashley.co.uk</a>
</p>
<div class="h6 fw-bolder">Follow us</div>
<a class="fs-5 px-2 link-dark" href="#!"><i class="bi-twitter"></i></a>
<a class="fs-5 px-2 link-dark" href="#!"><i class="bi-facebook"></i></a>
<a class="fs-5 px-2 link-dark" href="#!"><i class="bi-linkedin"></i></a>
<a class="fs-5 px-2 link-dark" href="#!"><i class="bi-youtube"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
.accordion-button::after {
content: '-';
background-image: none;
}
.accordion-button.collapsed {
background: #2f7485;
color:white;
}
.accordion-button:not(.collapsed)::after {
content: '+';
background-image: none;
}
.accordion-button:focus {
z-index: 3;
border-color: #279C88;
outline: 0!important;
/* I changed the color on this line */
/* If you do not want any color, just delete */
box-shadow: 0 0 0 0.25rem rgba(39, 156, 136, 0.25);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment