html - Bootstrap 5 Justify Content Center + Container Fluid Causing Unexpected Behavior
问题描述
I'm trying to create a div that takes up 8 columns, centered, in a large viewport, and takes up all 12 columns, centered, in all other viewports.
I tried to achieve this with justify-content-center, but for some reason it is not centering the content on small viewports:
Large viewports: content is centered as expected:
Small viewports: content is off-center slightly:
Here is the code:
<div class="row container-fluid justify-content-center">
<div class="main-container p-3 m-3 col-lg-8">
(text)
</div>
</div>
解决方案
I was able to achieve the desired effect with the following:
<div class="container-fluid">
<div class="row justify-content-center p-3">
<div class="main-container p-3 col-lg-8">
(text)
</div>
</div>
</div>
推荐阅读
- django - ManagementForm对应的数据不存在或已被修改
- javascript - “How to fix the 'div panel' in either CSS or JavaScript from closing
- javascript - 如何在jQuery中获取窗口选择中的单词数
- php - 使用 MediaWiki 1.32 访问 wiki 页面时出现问题,PHP 已过时
- python - 如何使物体在同一高度永远反弹
- javascript - innerHTML 的问题 - 无法识别来自 css 的类
- javascript - 有没有办法在没有 .then 的情况下每次都解开一个承诺?
- scala - 组合地图的所有值,其中每个值都是一个数据框
- javascript - 如何在移相器 3 中以随机延迟循环函数回调?
- flutter - Flutter for web - 我在哪里放置图像以使用 AssetImage?