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 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制