如何让盒子中的文字水平,垂直居中

<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap 实例</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link
      rel="stylesheet"
      href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"
    />
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <style>
        .col {
            height: 50px;
            text-align: center;
            line-height: 50px;
        }
    </style>
  </head>
  <body>
    <div class="jumbotron text-center">
      <h1>谁若游戏人生,他就一事无成;谁不主宰自己,永远是一个奴隶。</h1>
    </div>

    <div class="container">
      <div class="row">
        <div class="col-sm-4">
          <h3>第一条</h3>
          <p>
            人生的前期,要是你越嫌麻烦,越懒得学,后来就越可能错过让你动心的人和事,错过新风景。
          </p>
        </div>
        <div class="col-sm-4">
          <h3>第二条</h3>
          <p>
            人生的前期,要是你越嫌麻烦,越懒得学,后来就越可能错过让你动心的人和事,错过新风景。
          </p>
        </div>
        <div class="col-sm-4">
          <h3>第三条</h3>
          <p>
            人生的前期,要是你越嫌麻烦,越懒得学,后来就越可能错过让你动心的人和事,错过新风景。
          </p>
      </div>
    </div>
    <div class="container-fluid">
        <h1>创建相等宽度的列</h1>
        <p>创建三个相等宽度的列! 尝试在 class="row" 的 div 中添加新的 class="col"  div,会显示四个等宽的列。</p>
        <div class="row">
          <div class="col" style="background-color:lavender;">哈哈</div>
          <div class="col" style="background-color:orange;">呵呵</div>
          <div class="col" style="background-color:lavender;">嘿嘿</div>
        </div>
      </div>
  </body>
</html>

Guess you like

Origin blog.csdn.net/liulang68/article/details/121429414