我的 php 页面中有一个 div,如下所示
<div class="col-md-16" id="">
<div class="textwidget">
<?php while ($row = mysqli_fetch_array($queryResult)) { ?>
<div style="margin-bottom: -15px; margin-right: 20px; background-color: #008086;">
<img class="alignnone wp-image-401" src="uploads/2016/12/homa-1-300x199.png" alt="" width="56" height="37" style="margin-bottom: -19px;" />
<span class="About-us-Description" style="color: #ffffff;"><?php echo $row['Name'] ?></span><hr>
</div>
<div class="textwidget">
<?php
$query1 = "Select * from rituals where ritualtypeid=".$row['ritualtypeid'];
$queryResult1 = mysqli_query($dbcon, $query1);
?>
<?php while ($row1 = mysqli_fetch_array($queryResult1)) { ?>
<div class="Homas">
<a style="color: #000000;" href="">
<i class="fa fa-angle-right"></i> <span class="what-we-offer" style="color: #000000;">
<?php echo $row1['Name'] ?>
</span>
</a><br />
</div><?php } ?>
</div><?php } ?>
</div>
</div>
它将结果显示为
**Heading1**
Content1
Content2
**Heading2**
Content3
Content4
**Heading3**
Content5
Content6
**Heading4**
Content7
Content8 so on
但实际上我要显示的是
**Heading1** **Heading2** **Heading3**
Content1 Content3 Content5
Content2 Content4 Content6
---------------------------------------------------
**Heading4**
Content7
Content8 so on
在 3 个 div 之后我需要一个换行符,接下来 div 应该出现在下一行。怎么做。任何帮助表示赞赏。
最佳答案
您的代码确实没有解释您的输出,但无论如何,如果您使用的是 twitter bootstrap,那么您需要为所有元素提供一个 col-md-4
类并将它们包装在 row-fuild
div.像这样:
<div class="row-fluid">
<div class="col-md-4" id="" >
<div class="textwidget"><?php while ($row = mysqli_fetch_array($queryResult)) { ?>
<div style="margin-bottom: -15px; margin-right: 20px; background-color: #008086;">
<img class="alignnone wp-image-401" src="uploads/2016/12/homa-1-300x199.png" alt="" width="56" height="37" style="margin-bottom: -19px;" />
<span class="About-us-Description" style="color: #ffffff;"><?php echo $row['Name'] ?></span><hr></div>
<div class="textwidget">
<?php
$query1 = "Select * from rituals where ritualtypeid=".$row['ritualtypeid'];
$queryResult1 = mysqli_query($dbcon, $query1);
?>
<?php while ($row1 = mysqli_fetch_array($queryResult1)) { ?>
<div class="Homas"><a style="color: #000000;" href="">
<i class="fa fa-angle-right"></i> <span class="what-we-offer" style="color: #000000;">
<?php echo $row1['Name'] ?> </span></a><br />
</div><?php } ?>
</div><?php } ?>
</div>
</div>
</div>
关于php - 重新排列html中的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41887411/