doutuan6158 2016-01-29 11:33
浏览 33
已采纳

msqli_fetch_array或assoc和css获取空格

I am developing a simple project but encountered a problem which I can not find solution.

The follow php code:

<?php include "header.php"; ?>
<?php
    $subtitle = "Os teus animes favoritos diariamente!";
    $conn = mysqli_connect("$host","$dbuser","$dbpw","$db");

        if (mysqli_connect_errno())
         {
        echo "Falha ao ligar à Base de Dados: " . mysqli_connect_error();
         }

    $result = mysqli_query($conn, "SELECT * FROM m_capitulos ORDER BY 'm_capitulos'.'id_cap' DESC LIMIT 30") or die(mysqli_error($conn));
    mysqli_close($conn);
?>
<section class="mbr-section mbr-section--relative mbr-section--fixed-size mbr-after-navbar" id="features1-3" style="background-color: rgb(255, 255, 255);">
<div class="mbr-section__container container"><!-- "mbr-section__container--std-top-padding" para dar padding no top! -->
    <div class="mbr-section__row row">

    <?php while ($row = mysqli_fetch_array($result)){ ?>
        <div class="mbr-section__col col-xs-12 col-sm-4">
            <div class="mbr-section__container mbr-section__container--center mbr-section__container--middle">
                <a href="/assistir/<?php echo $row['seo']; ?>"><figure class="mbr-figure"><img class="mbr-figure__img" src="<?php echo $row['p_thumb']; ?>"></figure></a>
            </div>
            <div class="mbr-section__container mbr-section__container--middle">
                <div class="mbr-header mbr-header--reduce mbr-header--center mbr-header--wysiwyg">
                    <h3 class="mbr-header__text"><a href="/assistir/<?php echo $row['seo']; ?>"><?php echo $row['nombre_cap']; ?></a></h3>
                </div>
            </div>
            <div class="mbr-section__container mbr-section__container--last">
                <div class="mbr-buttons mbr-buttons--center"><a href="<?php echo $row['p_descarga']; ?>" target="_blank" class="mbr-buttons__btn btn btn-wrap btn-xs-lg btn-default"alt="Download Regular">DOWNLOAD</a></div>
                <br>

                <div class="mbr-buttons mbr-buttons--center"><a href="<?php echo $row['p_descargavip']; ?>" target="_blank" class="mbr-buttons__btn btn btn-wrap btn-xs-lg btn-default" alt="Download Premium">DOWNLOAD</a></div>

                <br>
                <div class="mbr-buttons mbr-buttons--center"><a href="/assistir/<?php echo $row['seo']; ?>" target="_blank" class="mbr-buttons__btn btn btn-wrap btn-xs-lg btn-default" alt="Assisir Online">ASSISTIR</a></div>
            </div>
        </div>
        <?php } ?>

    </div>
</div>
</section>
<?php include "footer.php"; ?>

But when I remove the page css the empty space between the results disappears.

The Empty Space on the midle of my content box :

enter image description here

  • 写回答

1条回答 默认 最新

  • dongxin9759 2016-01-29 12:01
    关注

    The result on the right just above the space is shorter, thus the next element goes below it instead of going to next row. I suggest you split elements into groups of 3 so that they can go into rows, or alternatively set the height for each result so that they all line up.

    The example below adds a counter; every time you run through an element it checks if the element count divides by three, and if so, starts a new row. The same check is done at the end, except that it checks whether the element is the last in the row-of-three, and if so, ends the row tag.

    <?php
    $i = 0;
    while ($row = mysqli_fetch_array($result)){ ?>
        <?php if ($i % 3 == 0): ?><div class="row"><?php endif; ?>
        <div class="mbr-section__col col-xs-12 col-sm-4">
            <div class="mbr-section__container mbr-section__container--center mbr-section__container--middle">
                <a href="/assistir/<?php echo $row['seo']; ?>"><figure class="mbr-figure"><img class="mbr-figure__img" src="<?php echo $row['p_thumb']; ?>"></figure></a>
            </div>
            <div class="mbr-section__container mbr-section__container--middle">
                <div class="mbr-header mbr-header--reduce mbr-header--center mbr-header--wysiwyg">
                    <h3 class="mbr-header__text"><a href="/assistir/<?php echo $row['seo']; ?>"><?php echo $row['nombre_cap']; ?></a></h3>
                </div>
            </div>
            <div class="mbr-section__container mbr-section__container--last">
                <div class="mbr-buttons mbr-buttons--center"><a href="<?php echo $row['p_descarga']; ?>" target="_blank" class="mbr-buttons__btn btn btn-wrap btn-xs-lg btn-default"alt="Download Regular">DOWNLOAD</a></div>
                <br>
    
                <div class="mbr-buttons mbr-buttons--center"><a href="<?php echo $row['p_descargavip']; ?>" target="_blank" class="mbr-buttons__btn btn btn-wrap btn-xs-lg btn-default" alt="Download Premium">DOWNLOAD</a></div>
    
                <br>
                <div class="mbr-buttons mbr-buttons--center"><a href="/assistir/<?php echo $row['seo']; ?>" target="_blank" class="mbr-buttons__btn btn btn-wrap btn-xs-lg btn-default" alt="Assisir Online">ASSISTIR</a></div>
            </div>
        </div>
        <?php if ($i % 3 == 2): ?></div><?php endif;
        $i++
        ?>
    <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来