php - CSS 网格未对齐

标签 php html css mysql

我正在尝试使用 CSS 网格创建一个简单的页面。 在使用 MySQL 插入 php 函数之前,结果非常好。

CSS

.thumbnail
{
    margin-bottom: 20px;
    padding: 0px;
    -webkit-border-radius: 0px;
    -moz-border-radius: 0px;
    border-radius: 5px;
    width: 350px;
}

HTML/PHP

<div class="container text-center">
    <br>
    <div class="item col-lg-4">
        <div class="thumbnail">
            <br>
            <?php if ($fetch['file_name'] == '') { ?>
                <img class="img-fluid" src="../images/missing.png" alt="Sample image" style="height:150px; width:150px;">
            <?php } else { ?>
                <img class="img-fluid" src="../images/<?php echo $fetch['file_name']; ?>" alt="missing.png" style="height:150px; width:150px;"/>
            <?php } ?>

            <div class="caption">
                <h4><?php echo $fetch['school_name']; ?></h4>
                <p><?php echo $fetch['email']; ?></p>
                <p class="lead">$21.000</p>
                <a class="btn2" href="profileorg.php?Org_ID=<?php echo $fetch['Org_ID'] ?>">View profile</a>
            </div>
        </div>
    </div>
    <?php } ?>
</div>

截图如下

这是我的问题:

插入php函数后
After inserting php function

我想要的是这样的网格对齐:

引用
Reference

最佳答案

    <div class="container text-center">
    <br>
    <div class="item col-lg-4">
        <div class="thumbnail">
            <br>
            <?php if ($fetch['file_name'] == '') { ?>
                <img class="img-fluid" src="../images/missing.png" alt="Sample image" style="height:150px; width:150px;">
            <?php } else { ?>
                <img class="img-fluid" src="../images/<?php echo $fetch['file_name']; ?>" alt="missing.png" style="height:150px; width:150px;"/>
            <?php } ?>

            <div class="caption">
                <h4><?php echo $fetch['school_name']; ?></h4>
                <p><?php echo $fetch['email']; ?></p>
                <p class="lead">$21.000</p>
                <a class="btn2" href="profileorg.php?Org_ID=<?php echo $fetch['Org_ID'] ?>">View profile</a>
            </div>
        </div>
    </div>
</div>

可能是因为您插入了额外的右大括号。这段代码可以正常工作。

关于php - CSS 网格未对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54731785/

相关文章:

html - 获取 SQL 数据库邮件以格式化具有 2 列的 HTML 表

如果 CSS 中的边距为负数,jQuery .Show() 不起作用

javascript - 根据页面中的某些条件插入CSS

php - 如何防止两个顾客同时购买一件商品

javascript - D3 javascript从mysql中提取数据未捕获类型错误

php - Elasticsearch中[GeoDistanceSort]的非法纬度值

css 继承 - 测验 12

php - 获取没有命名空间的已执行静态函数的类名

php - 如何从 PHP 回显接收数据以使用 AJAX 显示?

javascript - 使用 CSS 和 JavaScript 对输入焦点上的标签进行动画处理