duanjiao6711 2015-12-07 13:42
浏览 40
已采纳

引导网格和mysql响应的问题

I have an issue with bootstrap and creating a 4 column responsive grid from a mysql response. The problem is that if the second mysql query has a variable number of results, it brakes the grid.

Here is my code (where the first query has 9 results and the second query has a variable number of results):

<?php
$a = "SELECT * FROM $table_users ORDER BY username";
$result = mysql_query($a);
?>
<div class="container">
    <div class="row">
        <?php while ($row = mysql_fetch_array($result)) {?>
        <div class="col-xs-3" style="background-color:aqua;">
            <?php echo $row['username'];
            $b = "SELECT * FROM $table_presents WHERE bought_for='$row[username]' OR bought_for='' ORDER BY id";
            $result_presents = mysql_query($b) or die(mysql_error());
            while ($row_presents = mysql_fetch_array($result_presents)) {
            ?>
            <div style="background-color:red;">
                Hello world!
            </div>
            <?php }?>
        </div>
        <?php }?>
    </div>
</div>

which gives me this:

enter image description here

instead of this (obviously with many 'Hello world'):

enter image description here

Any help greatly appreciated!

  • 写回答

2条回答 默认 最新

  • doujianmin6527 2015-12-07 13:51
    关注

    Bootstrap doesn't claim to do any kind of elegant bin-packing on panels with different sizes. You could do some programming or css work to make all your panels the same size.

    If that doesn't work for your application, you're going to need a layout library that does bin-packing so these panels of different sizes align properly.

    There are a few such libraries available as jQuery plugins.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻看一个题
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)