如何在CSS中对齐文本

时间:2016-02-22 02:45:52

标签: css

我想对齐文字,如:

enter image description here

但我的显示如下:

enter image description here

CSS代码:

  .caption > p
   {
       color: black;
       width: 100%;
       margin-top: 0px;
       text-align: center;
   }

HTML:

  <div class="col-sm-3 col-md-3">
      <div class="thumbnail"> 
          <div class="caption">
           <h3>Preventive Maintenance</h3>
              <p>
                  As a team starts to schedule preventive maintenance they need a reliable 
work calendar. CMMS systems are especially good at scheduling recurring work and sending 
reminders to the right people. Organized scheduling helps even out the workload for a 
maintenance team making sure that tasks do not get forgotten
              </p>
          </div>
      </div>
    </div>

我已经尝试了float: left, and float: right但它不起作用,有什么技巧可以解决这个问题吗?

1 个答案:

答案 0 :(得分:3)

使用text-align: justify;代替text-align: center;

有关更多选项,请参阅https://developer.mozilla.org/en/docs/Web/CSS/text-align#Values