Is it possible to create a table with rows that adjust their size based on the screen size? For example, 3 elements for large screens, 4 for medium screens, and 2 for small screens.
Below is the code I used to achieve this:
<div class=row>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
</div>
Now, I want each element to target another collapsible .col-12
div. The challenge lies in having these elements fill the entire column and display correctly in the green area. On larger screens, there should be 3 targeted divs, on medium screens 4, and on smaller screens just 2.
Take a look at my sketch to better understand:
https://i.sstatic.net/Y6cNk.png
The issue I'm facing is that when I add an element below my col-* divs, the other columns shift down under those added elements.
<div class=row>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
<p>MY ELEMENT</p>
</div>
<div class="col-12 collapse bg-success" id="collapseExample" >
<p>COLLAPSE ELEMENT</p>
</div>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
<div class="col-lg-4 col-md-3 col-sm-6 bg-danger">
<p>MY ELEMENT</p>
</div>
</div>
https://i.sstatic.net/Bjd2E.png
How can I ensure that my green div displays without causing the other columns to go underneath it?