html - 无法在 Bootstrap 行中居中放置某些文本

标签 html css twitter-bootstrap twitter-bootstrap-4

我正在尝试将一些文本居中放置。我觉得这不应该这么困难,我很困惑为什么它不起作用。

图片(示例)

enter image description here

#title_img {
  background-image: url(http://cdn.playbuzz.com/cdn/UserImages/4343091c-c906-457b-b885-77675c22c92f.jpg);
  height: 180px;
  width: 180px;
  margin: 0 auto;
}
#title_img_holder {
  padding-top: 5%;
  float: none;
  margin: 0 auto;
}
#title_holder {
  text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid" id="header_con">
  <div class="container">
    <div class="row" id="title_img_holder"> <img src="http://cdn.playbuzz.com/cdn/UserImages/4343091c-c906-457b-b885-77675c22c92f.jpg" class="mx-auto" alt="Smiley face" height="180" width="180"> </div>
    <div class="row" id="title_holder">
      <h2 class="text-center">We fix screens.
        <small class="text-muted">Not for free though</small>
      </h2>
    </div>
  </div>
</div>

我使用的是最新版本的 boostrap 4

最佳答案

添加此 CSS:

#title_holder h2 {
    margin: 0 auto;
}

(您必须将 h2 在其父容器中居中)

http://codepen.io/anon/pen/QpqQYq

关于html - 无法在 Bootstrap 行中居中放置某些文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42822258/

相关文章:

php - 通过复选框选择无法正确删除图像

html - 将多个 div 元素彼此对齐,同时保持响应能力

ruby-on-rails - 试图让 Twitter 光标与 api 一起工作

html - 无填充对齐元素

javascript - 是否可以在加载内容时将加载程序图像放入 iframe 中?

css - Font Awesome 图标丢失

javascript - 用于检索页面内容的 innerHTML 替代方案?

html - CSS 样式消失了

javascript - Ionic 应用程序在 Chrome 和设备上滞后很多

html - 我无法在 bootstrap 4 中设置超大屏幕背景图片