My challenge is to optimize the spacing between 4 boxes based on screen size:
The layout should adjust as follows:
- If it's
xxl
or larger, all 4 boxes should be in a single horizontal row. - If it's
md
or larger, two boxes should be in the first row and the other two in another row. - Otherwise, each box should occupy its own row.
The current code snippet I am working with includes:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ddbfb2b2a9aea9afbcad9de8f3ecf3ee">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="container-fluid p-0 d-md-flex justify-content-md-evenly flex-md-wrap">
<div class="d-flex justify-content-center align-items-center border" style="width: 350px; height: 100px;">
<p>some content</p>
</div>
<div class="d-flex justify-content-center align-items-center border" style="width: 350px; height: 100px;">
<p>some content</p>
</div>
<div class="d-flex justify-content-center align-items-center border" style="width: 350px; height: 100px;">
<p>some content</p>
</div>
<div class="d-flex justify-content-center align-items-center border" style="width: 350px; height: 100px;">
<p>some content</p>
</div>
</div>
This code handles cases 1 and 3 but has difficulty with case 2. Although grouping the first two boxes and last two boxes separately could solve this issue, it would prevent achieving case 1.