CSS Bootstrap 类“文本中心”不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41208736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap class "text-center" not working
提问by Archin Modi
回答by UzumakiL
I was facing the same problem in Bootstrap 4.1.0. Here is what I figured out:
我在 Bootstrap 4.1.0 中遇到了同样的问题。这是我想出的:
I was doing this (having my paragraph inside div with class "row"):
我正在这样做(将我的段落放在带有“row”类的 div 中):
<div class="container-fluid">
<div class="row" style="background-color: #009688;">
<p class="text-center" style="color: #fff;"> Meet me at</p>
</div>
</div>
Later I removed the class and it worked.
后来我删除了这门课,它奏效了。
<div class="container-fluid">
<div style="background-color: #009688;">
<p class="text-center" style="color: #fff;"> Meet me at</p>
</div>
</div>
回答by Faisal
Bootstrap 3
引导程序 3
<p class="text-left">Left aligned text.</p>
<p class="text-center">Center aligned text.</p>
<p class="text-right">Right aligned text.</p>
<p class="text-justify">Justified text.</p>
<p class="text-nowrap">No wrap text.</p>
Bootstrap 4
引导程序 4
<p class="text-xs-left">Left aligned text on all viewport sizes.</p>
<p class="text-xs-center">Center aligned text on all viewport sizes.</p>
<p class="text-xs-right">Right aligned text on all viewport sizes.</p>
<p class="text-sm-left">Left aligned text on viewports sized SM (small) or wider.</p>
<p class="text-md-left">Left aligned text on viewports sized MD (medium) or wider.</p>
<p class="text-lg-left">Left aligned text on viewports sized LG (large) or wider.</p>
<p class="text-xl-left">Left aligned text on viewports sized XL (extra-large) or wider.</p>
回答by Kenneth Rhodes
It's most likely that you have your own stylesheet and your <h4>
tag has text-align: left;
or something like that. It could be .input-group
or .Flugo_group
as well. We'd need to see your code though.
很可能您有自己的样式表,并且您的<h4>
标签有text-align: left;
或类似的东西。它可以是.input-group
或也可以.Flugo_group
。不过,我们需要查看您的代码。
Edit: Or even something as simple as what contains any of your code could be the problem.
编辑:或者甚至像包含您的任何代码这样简单的东西都可能是问题所在。
回答by Hanif
Which version of Bootstrap you using are? I'm not get any class "text-center" in Bootstrap 3.3.7. So be confirm that in your Bootstrap css files contains any class like that. If not you can add your own class with text-align: center;
您使用的是哪个版本的 Bootstrap?我在 Bootstrap 3.3.7 中没有得到任何“文本中心”类。因此,请确认您的 Bootstrap css 文件中包含任何类似的类。如果没有,您可以使用 text-align: center; 添加自己的类。