【发布时间】:2022-01-28 22:22:58
【问题描述】:
我有 4 个盒子,我正在尝试在它们之间设置均匀的空格。
这些框的排列取决于屏幕尺寸:
- 如果是
xxl+,则 4 个框排成一条水平线(行)。
- 否则,如果是
md+,那么第一行有两个框,另外两个在另一行。
- 否则,每一个都排成一行。
我有这个代码:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/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>
此代码得到 1. 和 3. 完成(但不是 2. 因为在某一点上,单个盒子被单独包装)。
我可以解决这个问题并获得 2. 和 3. 通过将前两个框一起包装在一个 div 中,最后两个一起包装在另一个 div 中,但是我无法实现 1.
【问题讨论】:
标签: css bootstrap-4 bootstrap-5