I am trying to decrease the margin between the (header__title-title) and the first item (header__title-symbol) in the flex container. I can't seem to get anything to work. Any suggestions? The main axis is vertical since I have the flex-direction set to 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;
}
CodePudding user response:
I think your problem does not related to CSS flex property. you could add these lines in your CSS file:
*, *::after, *::before {
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
This code resets the margin and padding of all elements in your html file. Then you can set each amount of margin or padding that you want to the .header__title-title
class that is suitable for your design. for example:
.header__title-title {
padding-top: 20px;
}
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
There are multiple ways by which you can achieve this.
- Add a
margin-top
ormargin-bottom;
to the ones you want to add space. - When you add display: flex and flex-direction: column, then by using
justify-content: space-between;
Hope this works for you.