【发布时间】:2018-09-08 19:16:02
【问题描述】:
<article>
<div class="container">
<div class="row">
<div class="col-12 col-md-6 col-lg-4 mb-3 mb-md-0">
<?php foreach ($publicacao as $pl): ?>
<div class="card">
<div class="img-container">
<a href="index.php?post=<?php echo $pl['title']?>">
<img src="<?php echo $pl['capa']?>" alt="<?php echo $pl['alt']?>" class="card-img-top">
</a>
</div>
<div class="card-body">
<a href="index.php?post=<?php echo $pl['title']?>" class="card-title cardTitleLink">
<h2 class="cardTitle"><?php echo $pl['title']?></h2>
</a>
<p class="card-text text-muted"><?php echo $pl['text']?></p>
<a href="index.php?post=<?php echo $pl['title']?>" class="btn btn-outline-danger btn-sm">Continue Lendo</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</article>
我有这个脚本,它从我的数据库中返回记录。我在数据库中有 10 条记录,问题是卡片在一条垂直线上,一个在另一个之上。正确的做法是让卡片水平对齐,我该怎么做?
【问题讨论】:
-
使用
css- 类似于float:left;clear:none;应用于每张卡。 -
@RamRaider 它不起作用:/
-
@RamRaider 可以解决这个问题吗?我是 Bootstrap 的新手。
-
查看我发布的答案!
标签: php html database twitter-bootstrap foreach