Find the image here to understand what i'm talking about
我一直在谷歌上搜索和摆弄,但我似乎无法将单词分开。我所做的唯一的分离就是使用"justify-content: space-justify“。
这是HTML。CSS在它的下面
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;
}
<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>
发布于 2021-08-20 05:15:27
在header-container中使用display:flex和justify-content:center;这将使子p标记在一行中,没有任何空格。如果您只需要p标记周围的小空间,可以添加
.header-container p {
padding: 0 5px;
}
如果你想了解flex和它的属性,你可以从这里学习,csstricks已经很好地解释了它。我希望这对你有用。
谢谢
发布于 2021-08-20 05:05:10
您可以将<p>Your header</p>
更改为<pre>Your Header</pre>
。在这里,<pre>
保持文本的格式,包括空格。您可以查看此页面:https://www.w3schools.com/tags/tag_pre.asp
基本上,您只需要在您的代码中编辑以下内容:
<pre class="logo-the logo">The </pre> <pre class="logo-big logo">Big </pre> <p class="logo-three logo">Three</p>
我在"The“和"Big”后面加了一个空格,所以把它们转换成了<pre>
。
https://stackoverflow.com/questions/68857154
复制相似问题