html - 我怎样才能使所有带有边距的项目居中?
问题描述
任何人都可以如何帮助我在此代码中将所有带有边距的项目居中
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>
解决方案
要使文本居中,请使用 text-align: center;
要使图像水平居中最好使用 flex-box,只需 3 行代码。无论图像尺寸如何,这都会使所有内容居中。
.se {
display: flex;
flex-direction: column;
align-items: center;
}
.sep {
text-align: center;
}
推荐阅读
- javascript - Jquery将类添加到不同按钮上的div
- javascript - Javascript 控制台在折叠和展开时显示不同的值,并且与引用时不同
- python - 找不到 panda.tslib 模块
- c# - 如何使用 HTTP get 方法从数据库中请求数据?
- python - 即使我将目录下载到 nltk.data.path 的路径列表中,NLTK 也找不到路径
- python - 通过opencv Python检测图像中是否有灰色
- reactjs - React route,在 CoreUI 上使用具有不同 props/parameters 的相同组件
- laravel - Laravel:如何从数据库中设置复选框的值
- arrays - 在 Go 中,如何解组包含结构数组的字符串
- teradata - Teradata - 如何避免发生多次重新分配