html - bootstrap + django,包装卡

标签 html django bootstrap-4

我有一个简单的问题。

我将循环遍历数据库记录并为每条记录打印一张卡片。问题是,如果我不能为每一行设置一个新行,我最终会在两行卡片之间出现这种可怕的挤压布局

我怎样才能循环遍历,为每个卡片制作一张卡片并且仍然使它看起来不错?

谢谢!!

enter image description here

<div class="row">

<div class="col-4"> 
<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
</div>
</div>

<div class="col-4"> 
<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
</div>
</div>

<div class="col-4"> 
<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
</div>
</div>

<div class="col-4"> 
<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
</div>
</div>
</div>

最佳答案

只需使用间距实用程序即可。例如:

<div class="col-4 py-3"> 
  <div class="card" style="width: 18rem;">
  ...
  </div>
</div>

关于html - bootstrap + django,包装卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54012381/

相关文章:

html - 仅悬停单词时限制工具提示显示

python - 删除可为空字段就是删除相关对象

python - Celery Cloudamqp 为每个任务创建新连接

css - 将轮播标题移到轮播外

css - 具有 bootstrap-4 种不同盒子高度的响应式盒子网格

html - 网格应该是水平的但显示为垂直

Javascript 在数组对象中移动 .active 类

php - 不同宽度的首页和文章页

javascript - 表单操作不起作用

python - Django REST 框架 : "This field is required." with required=False and unique_together