php - 重新排列html中的div

标签 php html css twitter-bootstrap

我的 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/

相关文章:

html - 对齐页脚的方法?

php - 计算结束日期 : PostgreSQL 的年份

php - 使用 between、min 和 max 的问题

php - 表单/PHP/Ajax 加载?

php - Twig 模板单元测试

php - 是否可以在Elasticsearch索引上使用AJAX和PHP实现实时搜索

html - 浏览器能否在 SVG 元素本身之外呈现 svg 元素的某些部分?

javascript - 将 D3.js 创建的下拉菜单交换为 HTML 创建的下拉菜单

html - CSS 有奇怪的问题

html - 以最大高度 flex