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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:17:53  来源:igfitidea点击:

Bootstrap class "text-center" not working

cssbootstrap-modal

提问by Archin Modi

<div class="input-group Flugo_group">
     <h4 class="text-center">or</h4>
</div>

i am try to show in center but not working.second time using position relative but not working properly in responsive design. center

我试图在中心显示但不工作。第二次使用相对位置但在响应式设计中无法正常工作。 中央

回答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

v3 Text Alignment Docs

v3 文本对齐文档

<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

v4 Text Alignment Docs

v4 文本对齐文档

<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-groupor .Flugo_groupas 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; 添加自己的类。