引导程序:居中col-md-5? [英] Bootstrap: Centering col-md-5?
问题描述
我觉得这是一个很奇怪的问题,但是我似乎无法在线找到解决方案。
I feel like this is a very weird question but I couldn't seem to find a solution online.
如果我有一个 col -md-5
,我似乎无法居中。
据我了解的网格系统,如果我选择列大小(1-12),为了控制列的位置,我使用col-##-offset-#。
If I have a col-md-5
, I can't seem to center it.
As far as I understood the grid system, if I choose a column size (1-12), in order to control the position of the column I use col-##-offset-#.
因此,如果我有 col-md-4
,我会使用 col-md-offset-4
将其从左侧推4列,然后将其居中。想法是,要使列居中,网格内的左侧和右侧必须有相同数量的列。
So if I have a col-md-4
, I would use col-md-offset-4
to push it 4 columns from the left, and then it will be centered. The idea is that, to center a column, there must be the same amount of columns within the grid from the left of it and from the right of it.
现在,如果我有一个 col-md-5
怎么办?我如何居中?
做类似 col-md-4
的操作会在右边留下3。我尝试了几件事但没有成功。
Now, what if I have a, let's say, col-md-5
? How can I center it?
Doing something like col-md-4
will leave 3 from the right. I tried several things but no success.
预先感谢。
推荐答案
引导程序4
在引导程序4中,只需使用 mx-auto
用于自动左/右页边距...
In Bootstrap 4 this can be done simply with mx-auto
for auto left/right margins...
<div class="container">
<div class="row">
<div class="col-sm-5 mx-auto">
Centered
</div>
</div>
</div>
这篇关于引导程序:居中col-md-5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!