如何在sql字符串中的每个第3个帖子中添加clearfix

时间:2016-11-23 19:54:05

标签: php css html5 responsive-design

有没有办法我可以添加.clearfix {clear:both;}到sql字符串的每三个帖子而不会搞乱帖子的顺序?因为如果你现在在我的页面上查看源代码,这是每个帖子的外观(减去sql的东西)我需要清除每个第3个帖子,以便我的行排成一行,但不知道如何做。任何帮助将不胜感激

    <div class="row block02">
                            <? **sql stuff**
                            ?>
    <div class="col-1-3">
        <div class="wrap-col">

            <a href="blog.php?post_id=<? echo($result_miniblog['post_id']); ?>"><img src="../images/<? echo($result_miniblog['image']); ?>" alt="<? echo($result_miniblog['image_alt']); ?>" /></a>
        <h2>    
            <a class="tag" style="color:#2980b9;" href="#"><? echo($result_miniblog['post_category']); ?></a>
            <a class="headline" href="blog.php?post_id=<? echo($result_miniblog['post_id']); ?>"><? echo($result_miniblog['post_title']); ?></a>
            <a class="byline" href="blah">
            <br />John Doe</a>
        </h2>
        </div>
    </div>

                            <?}?>

</div>

2 个答案:

答案 0 :(得分:0)

在你的sql中,你可能有一个索引(或者可以很容易地创建一个)来知道你当前循环的枚举。如果modulus of the index and your loop为零,则打印clearfix。

ajaxStart

答案 1 :(得分:0)

你也可以在css中使用伪元素:Sub changeHeadersFooters(openedDoc As Object, tempDoc As Object) Dim shp As Object, logo As Object Dim HdFt As Object, hdrOpened As Object 'create logo object in template doc For Each HdFt In tempDoc.Sections(1).footers If HdFt.Exists Then For Each shp In HdFt.Shapes If InStr(shp.Name, "image") <> 0 Then Set logo = shp: Exit For Next shp End If Next HdFt Set hdrOpened = openedDoc.Sections(1).footers(1) logo.Select Selection.Copy With hdrOpened.Range .Collapse Direction:=1 'wdCollapseStart=1, wdCollapseEnd = 0 .Paste End With End Sub 可能有效。

:nth-child(3n+1)
ul {
  list-style:none;
}
li {
  background:red;
  float:left;
}
li:nth-child(3n) {
  background:blue; 
}
li:nth-child(3n+1) {
  clear:both;
}