【发布时间】:2019-03-25 06:09:22
【问题描述】:
我有一个单行网格,一旦屏幕变得足够小,它应该将两个图像放在一起。
它工作正常,但是一旦屏幕变得太小,图像就不会居中。事实上,网格本身并没有居中。
我尝试了很多方法,但似乎没有任何效果。
我想要的只是当屏幕太小时两个图像在屏幕上居中。
所有代码都在一个组件内。并且组件本身位于 3 列网格内(即您看到的带有“左侧的东西”和“右侧的东西”标签的网格)。
这是我的代码。我改变了每个元素的背景颜色,所以我可以知道是什么。此外,我正在尝试以多种不同的方式将所有内容置于中心位置:
<body class="justify-content-md-center" style="justify-content: center; align-items: center; background-color: blue">
<div class="container justify-content-md-center" style="width: auto; justify-content: center; align-items: center; background-color: grey">
<div class="container center" style="justify-content: center; background-color: yellow"> <!-- global canvas -->
<div class="row no-gutters justify-content-md-center style="justify-content: center; background-color: red">
<div class="col-sm" style="justify-content: center; background-color: green">
<img src="./images/fssFront.png" class="img-fluid" alt="Responsive image">
</div>
<div class="col-sm">
<div class="center-content">
<img src="./images/fssBack.png" class="img-fluid" alt="Responsive image">
</div>
</div>
</div>
</div> <!-- global canvas -->
</div>
</body>
我对 CSS、html 和 bootstrap 还是很陌生。我确定我错过了什么。
你能帮帮我吗?
谢谢。
【问题讨论】:
-
从 justify 类中取出
md。它以任何比这更大的东西为中心。
标签: html css bootstrap-4