首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >我的网站标题,其中有3个字,将不会分开。感觉我什么都试过了?

我的网站标题,其中有3个字,将不会分开。感觉我什么都试过了?
EN

Stack Overflow用户
提问于 2021-08-20 04:52:26
回答 2查看 49关注 0票数 1

Find the image here to understand what i'm talking about

我一直在谷歌上搜索和摆弄,但我似乎无法将单词分开。我所做的唯一的分离就是使用"justify-content: space-justify“。

这是HTML。CSS在它的下面

代码语言:javascript
代码运行次数:0
运行
复制
body {
  background-color: #3269a8;
}

.header-container {
  display: flex;
  width: 100%;
  height: 50px;
  background-color: #282828;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
}

.logo {
  color: white;
  font-family: 'Titillium Web', sans-serif;
  font-size: 25px;
}

.logo:hover p {
  transition: 2000ms;
  font-size: 30px;
}
代码语言:javascript
代码运行次数:0
运行
复制
<html>
<head>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@600&display=swap" rel="stylesheet">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="style.css">
  <title>Top 3 Anime</title>
</head>
<body>

  <div class="header-container">
    <p class="logo-the logo">The</p> <p class="logo-big logo">Big</p> <p class="logo-three logo">Three</p>
  </div>

  <div class="top3">

    <div class="onepiece">One Piece</div>
    <div class="dragonball">Dragon Ball Z</div>
    <div class="naruto">Naruto</div>

  </div>

</body>
</html>

EN

回答 2

Stack Overflow用户

发布于 2021-08-20 05:15:27

在header-container中使用display:flex和justify-content:center;这将使子p标记在一行中,没有任何空格。如果您只需要p标记周围的小空间,可以添加

代码语言:javascript
代码运行次数:0
运行
复制
.header-container p {
  padding: 0 5px;
}

如果你想了解flex和它的属性,你可以从这里学习,csstricks已经很好地解释了它。我希望这对你有用。

谢谢

票数 0
EN

Stack Overflow用户

发布于 2021-08-20 05:05:10

您可以将<p>Your header</p>更改为<pre>Your Header</pre>。在这里,<pre>保持文本的格式,包括空格。您可以查看此页面:https://www.w3schools.com/tags/tag_pre.asp

基本上,您只需要在您的代码中编辑以下内容:

代码语言:javascript
代码运行次数:0
运行
复制
    <pre class="logo-the logo">The </pre> <pre class="logo-big logo">Big </pre> <p class="logo-three logo">Three</p>

我在"The“和"Big”后面加了一个空格,所以把它们转换成了<pre>

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68857154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档