Bootstrap段落在不同的列中对齐

时间:2016-03-07 21:23:22

标签: wordpress twitter-bootstrap

我正在尝试制作一个wordpress页面并使用以下代码:

<div class='container-fluid'>
    <div class='row'>
    <?php
     if(have_posts()):
        while(have_posts()):
            the_post();
            echo '<div class="col-sm-3 border">';
            the_title( '<h3>', '</h3>');  //echo <h3>The Title</h3>
            the_excerpt();
            echo '</div>';
        endwhile;
        endif;
     ?>
    </div>
</div>

blogroll显示如下:

Bootstrap align the rows

我想展示这样的东西:(对不起油漆)

no aligned

感谢您阅读

1 个答案:

答案 0 :(得分:0)

我对PHP并不是那么出色,但我认为你可以用Modulus做一些新的事情。

<div class='container-fluid'>
<div class='row'>
<?php

if(have_posts()):

    counter = 1;
    while(have_posts()):

        if (counter % 4 == 0) {
            echo '</div><div class="row">';
        }
        the_post();
        echo '<div class="col-sm-3 border">';
        the_title( '<h3>', '</h3>');  //echo <h3>The Title</h3>
        the_excerpt();
        echo '</div>';
        counter++;
    endwhile;
endif;
 ?>
</div>