我试图将我的标题居中,所以我使用了 white-space: nowrap;
所以它没有堆叠并且出现在一行中,但现在它不会居中。这样就有了标题的 CSS 代码,它的外观很好,唯一的问题是,它不是居中显示,而是从中心开始,并且一直向右移动。就像,它不是“与探索者见面”,而是“与探索者见面”
我的代码片段是:
.section-title { font-size: 4rem; font-weight: 300; color: black; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.2rem; clear: both; display: inline-block; overflow: hidden; white-space: nowrap; justify-content: center; }
<div class="about-top"> <h1 class="section-title">Meet the <span>SEE</span>kers</h1> <p>We are a team of young entrepreneurs, who decided it was time to modernize the way we search the web. A diverse group of unexpected talents came together to make SEE-Tool available to every web user.</p> </div>
P粉9860280392024-03-20 12:41:28
我不确定为什么你的代码中有 justify-content: center
,因为它在那里没有做任何事情。您也不需要 inline-block
因为 span
标签不是块元素。
您可以删除 display
属性并添加 text-align: center
,这样它将居中您的 h1
标记。
.section-title { font-size: 4rem; font-weight: 300; color: black; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.2rem; text-align: center; }
Meet the SEEkers
We are a team of young entrepreneurs, who decided it was time to modernize the way we search the web. A diverse group of unexpected talents came together to make SEE-Tool available to every web user.