【发布时间】:2023-03-30 14:46:02
【问题描述】:
尝试使用 flexbox 进行简单的网站重建。这是最终目标(对于这一步):
很简单。但我正在努力对齐文本。我能够让标题居中就好了。这主要是我无法居中的段落。有没有办法将该段落垂直和水平居中到其外部容器?刚接触 flexbox,希望有任何提示!这是我的 codepen 和相关代码的链接:https://codepen.io/gkunthara/pen/qjympg
HTML
<div class = "content-container">
<h1 class = "main-header"> Connect with Subscribers Effortlessly </h1>
<p class = "sub-header"> Email Marketing Platform for Bloggers &
Authors. </p>
</div>
CSS
.content-container .main-header{
box-sizing: border-box;
font-weight: 600;
font-size: 45px;
height:75px;
padding-left: 5px;
padding-right: 5px;
color: rgb(51, 51, 51);
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
border-style: solid;
}
.content-container .sub-header {
border-style: solid;
display: flex;
height: 25px;
margin-top: 150px;
}
【问题讨论】: