How to collapse the borders in the Bootstrap 4 accordion example?

Kurt Peek

I'd like to adapt the accordion example from https://getbootstrap.com/docs/4.0/components/collapse/#accordion-example. However, I've noticed that the borders in between the collapsible group items are wider than the ones at the top and bottom:

enter image description here

I think it would look nicer if the borders were all the same with, similar to using the borde-collapse property for tables. How might I achieve this?

Here is a snippet:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<div id="accordion">
  <div class="card">
    <div class="card-header" id="headingOne">
      <h5 class="mb-0">
        <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </button>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body">
        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" id="headingTwo">
      <h5 class="mb-0">
        <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </button>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
      <div class="card-body">
        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" id="headingThree">
      <h5 class="mb-0">
        <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </button>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
      <div class="card-body">
        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>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>

billy.farroll

To get the same border on each of these tabs, you need to edit the .card class. Like this:

.card {

  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #FFF;
  border: 0px solid rgba(0,0,0,.125); /*EDIT this part*/
  border-radius: 0.25rem;

}

This will make the border look like this on each:

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Bootstrap 4: Accordion does not collapse cards

Accordion doesn't work in Bootstrap 4 collapse

Nested Bootstrap Collapse (Accordion)

Bootstrap Accordion example not working with Angular 4 [innerHTML]

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

Bootstrap 2 or Bootstrap 3 how to collapse open accordion

Bootstrap 4 getting nav tabs to collapse with card accordion

Bootstrap 4 Collapse Accordion - always have one panel open

Bootstrap 4 collapse-accordion not working despite valid markup

how to collapse bootstrap 4 navbar

How to add toggling of expand/collapse icons to a Bootstrap accordion?

Bootstrap accordion: how to avoid page scroll when collapse or expand elements

How to collapse react-bootstrap accordion panel horizontally?

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

Accordion angularjs using bootstrap collapse

Bootstrap Collapse Accordion Hover is not consistent

how to change collapse inside collapse background color with different width inside. Accordion from bootstrap 4.5

How to make borders collapse (on a div)?

How to toggle animation of the collapse icon in Bootstrap 4?

bootstrap.js Accordion Collapse / Expand

bootstrap 3 accordion collapse does not work on iphone

Bootstrap Accordion Expand/Collapse All not functioning properly

Collapse/Expand buttons for the Search Bar Bootstrap Accordion

Bootstrap Accordion/Collapse Uncaught TypeError: Illegal invocation

Tab collapse in bootstrap 4

React & Bootstrap 4 Collapse

How to expand and collapse table row using Bootstrap Accordion and ASP.NET MVC?

How to remove Java FX Accordion default borders?

How to make images overlay card borders in bootstrap 4?