对齐CSS中的文本块

时间:2018-01-28 14:36:49

标签: html css

我的代码现在有点问题。我正在尝试制作一个网页。而现在我暂时停留在一点上。

我希望在我的网页上得到以下结果: enter image description here

这是我的源代码: HTML:



    #lp-pom-text-comment-marche p{
        text-align: center;
        margin-top: 20px;
      }

      #comment-marche {
        font-size: 21px; 
        font-family: Lato; 
        font-weight: 400; 
        font-style: normal;
      }

      #lp-pom-text-1 {
        width:300px;
      }

      #lp-pom-text-2 {    
        width:300px;
      }
      #lp-pom-text-3 {
        width:300px;
      }
      #lp-pom-text-4 {
        width:300px;
      }

<div class="lp-pom-block-content">
      <div class="lp-element lp-pom-text nlh" id="lp-pom-text-comment-marche">
        <p>
        <span id="comment-marche">Title</span>
        </p>
      </div>
      <div class="lp-element lp-pom-text nlh" id="lp-pom-text-1" style="height: auto;">
        <p style="text-align: center;">
        <span"><strong>1.</strong></span>
        </p>
        <p style="text-align: center;">
        <span>text text text text text text text text text text</span>
        </p>
      </div>
      <div class="lp-element lp-pom-text nlh" id="lp-pom-text-2" style="height: auto;">
        <p style="text-align: center;">
        <span><strong>2.</strong></span>
        </p>
        <p style="text-align: center;">
        <span>text text text text text text text text text text</span>
        </p>
      </div>
      <div class="lp-element lp-pom-text nlh" id="lp-pom-text-3" style="height: auto;">
        <p style="text-align: center;">
        <span><strong>3.</strong></span>
        </p>
        <p style="text-align: center;">
        <span>text text text text text text text text text text</span>
        </p>
      </div>
        <div class="lp-element lp-pom-text nlh" id="lp-pom-text-4" style="height: auto;">
        <p style="text-align: center;">
          <span><strong>4.</strong></span>
        </p>
        <p style="text-align: center;">
        <span>text text text text text text text text text text</span>
        </p>
      </div>
    </div>
&#13;
&#13;
&#13;

我从CSS开始,我仍然以不同的方式迷失方向。如果有人能给我一个轨道,以便我能达到预期的结果,请:)

谢谢:)

1 个答案:

答案 0 :(得分:1)

.container {
  display: grid;
  grid-template-rows: auto auto;
  grid-template-columns: auto auto;
  
  margin: 0 auto;
}

.lp-element{
  margin: 0 auto;
}

#lp-pom-text-comment-marche p{
    text-align: center;
    margin-top: 20px;
    
  }

  #comment-marche {
    font-size: 21px; 
    font-family: Lato; 
    font-weight: 400; 
    font-style: normal;
  }



  #lp-pom-text-1 {
    width:300px;
  }

  #lp-pom-text-2 {    
    width:300px;
  }
  #lp-pom-text-3 {
    width:300px;
  }
  #lp-pom-text-4 {
    width:300px;
  }
        <div class="lp-pom-block-content">
  <div class="lp-element lp-pom-text nlh" id="lp-pom-text-comment-marche">
    <p>
    <span id="comment-marche">Title</span>
    </p>
  </div>
    <div class="container">
  <div class="lp-element lp-pom-text nlh" id="lp-pom-text-1" style="height: auto;">
    <p style="text-align: center;">
    <span"><strong>1.</strong></span>
    </p>
    <p style="text-align: center;">
    <span>text text text text text text text text text text</span>
    </p>
  </div>
  <div class="lp-element lp-pom-text nlh" id="lp-pom-text-2" style="height: auto;">
    <p style="text-align: center;">
    <span><strong>2.</strong></span>
    </p>
    <p style="text-align: center;">
    <span>text text text text text text text text text text</span>
    </p>
  </div>
  <div class="lp-element lp-pom-text nlh" id="lp-pom-text-3" style="height: auto;">
    <p style="text-align: center;">
    <span><strong>3.</strong></span>
    </p>
    <p style="text-align: center;">
    <span>text text text text text text text text text text</span>
    </p>
  </div>
    <div class="lp-element lp-pom-text nlh" id="lp-pom-text-4" style="height: auto;">
    <p style="text-align: center;">
      <span><strong>4.</strong></span>
    </p>
    <p style="text-align: center;">
    <span>text text text text text text text text text text</span>
    </p>
  </div>
</div>

这就是你想要的吗?