I've hit a roadblock with this project. I'm working on setting up a FAQ section that needs to display its items in two columns on desktop, each with a drop shadow effect using Bootstrap 4.
I've experimented with Flexbox and CSS columns without success. Even tried implementing CSS Grid, but I'm facing an issue where expanding one accordion item causes the other side to expand as well. I've shared a codepen to illustrate the problem.
Update: I overlooked a crucial detail. This is for a Wordpress site, utilizing the Advanced Custom Fields (ACF) plugin to create a repeater field for the FAQ items. These items are outputted as an array, making the number of items unpredictable. They should be displayed in two columns, except when there's only one item.
The HTML structure is as follows:
<ul id="faq-accordion" class="list-unstyled">
<li class="card-faq" data-toggle="collapse" data-target="#collapse1" aria-expanded="false" aria-controls="collapse1">
<div class="card-header" id="heading1">
<h3>
<button class="btn btn-link">Accordion 1</button>
</h3>
</div>
<div id="collapse1" class="collapse multi-collapse" aria-labelledby="heading1" data-parent="#faq-accordion">
<div class="card-body">contents
</div>
</div>
</li>
</ul>
Here is a snippet of my SCSS:
#faq-accordion{
padding: 40px 30px 60px 30px;
display: grid;
grid-gap: 30px;
grid-template-columns: repeat(2, 50%);
grid-template-rows: auto;
grid-auto-flow: row;
height: auto;
width: 500px;
.card-faq{
margin: 0 15px 20px 15px;
border: none;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0,0,0,.1);
}
You can view the codepen here: https://codepen.io/LemonNick/pen/NEjJPQ
I would greatly appreciate any assistance or suggestions to overcome this challenge! It has been quite a struggle trying to figure it out.