dongou0524 2018-11-14 13:20
浏览 319

使用Bootstrap 4水平居中动态div.card

I'm listing articles from a database on a website based on Bootstrap 4. I would like the blocks (div.card) to always be centered horizontally no matter how much there are with a maximum of 3 blocks per line. I'm pretty sure there's a simple way to do it but my tests where unsuccessful so far.

Here's the page : http://www.0000.yelofox.fr/nos-actualites (You'll probably need to connect, I'm not sure as I'm logged in automatically. I can provide the password if needed)

The loop I use is made up that way :

echo '<section id="actualites" class="text-center">';
echo '<h2>Nos actualités</h2>';
echo '<div class="row">';
while ($data_news = mysqli_fetch_assoc($rq)){
    echo '<article class="card col-md-3">';
    echo '...';
    echo '</article>';
}
}
echo '</div>';
echo '</section>';

Let me know if you need further elements.

Thanks for you help

  • 写回答

1条回答 默认 最新

  • doushouj966020 2018-11-14 13:46
    关注

    Seeing that the class="text-center" didn't work. You can try the following...

    echo '<section id="actualites" class="text-center">';
    echo '<h2>Nos actualités</h2>';
    echo '<div class="row">';
    while ($data_news = mysqli_fetch_assoc($rq)){
        echo '<article class="card col-md-3" style="text-align: center !important;">';
        echo '...';
        echo '</article>';
    }
    }
    echo '</div>';
    echo '</section>';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配