首页 > 解决方案 > 我怎样才能使所有带有边距的项目居中?

问题描述

任何人都可以如何帮助我在此代码中将所有带有边距的项目居中

html代码

<div class="se">
  <div> <img class="seimg" src="images/we.jpg" alt=""></div>
  <div class="sep">
    <h2> Who we are?</h2>
    <p>We have been operating for over 30 years and are Members of The Federation of Master Builders. We work on projects big and small from small residential extensions to full house. We are so happy with this theme. Everyday it make our lives better.
    </p>
    <span>We care about environment.</span>
    <span>We are trusted by hundreds of clients.</span>
    <span>Social media loves us!</span>
    <span>This list is super easy to create</span>

  </div>
</div>

标签: htmlcss

解决方案


要使文本居中,请使用 text-align: center;
要使图像水平居中最好使用 flex-box,只需 3 行代码。无论图像尺寸如何,这都会使所有内容居中。

.se {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sep {
    text-align: center;
}

推荐阅读