【发布时间】:2021-11-06 18:11:42
【问题描述】:
我正在尝试减少 flex 容器中 (header__title-title) 和第一项 (header__title-symbol) 之间的边距。我似乎什么也做不了。有什么建议么?主轴是垂直的,因为我将 flex-direction 设置为 column
<div class="header__title">
<div class="header__title-symbol">
<span class="span-one"><hr id="hr-one" /></span>
<span id="symbol">⬙</span>
<span class="span-two"><hr id="hr-two" /></span>
</div>
<div class="header__title-title">
<h1>The Website title!</h1>
</div>
</div>
.header__title {
position: absolute;
top: 20%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.header__title-title {
letter-spacing: 4px;
color: white;
font-size: 2.5rem;
text-shadow: 0 4px 4px #d19224;
animation-name: moveInLeft;
animation-duration: 1s;
font-family: "Zen Kaku Gothic Antique", sans-serif;
}
.header__title-symbol {
display: flex;
flex-direction: row;
align-items: center;
}
hr {
width: 27rem;
display: inline-block;
height: 0.3rem;
background-color: white;
}
【问题讨论】:
-
在 Chrome 中,margin-block 属性会自动添加到 h1 标签中。看看在你的 CSS 中添加“h1 {margin-block: 0}”是否能解决你的问题。
-
请看我添加的图片。我正在尝试减少网站标题和上面的行之间的边距。您的解决方案不起作用@JuanManuelLópezManzano
-
嗨蒂姆,也许你可以减少行高