I can't center horizontally a h6 (or any) tag inside a flex div. I think I've tried all the CSS approaches align, justify, etc, but nothing works!
I just want to place a div with 80% of its size and put text inside it, is it supposed to be that hard?
[EDIT] Solved by adding margin 0 auto
(do not forgot the auto
) in the parent div css.
div {
display: flex;
align-items: center;
align-self: center;
justify-content: center;
width: 80%;
}
#n{border: 1px solid coral}
#y{border: 1px solid green}
h6{border: 1px solid blue}
<div id="n">
<h6>I won't align >:(</h6>
</div>
<br>
<div style="margin: 0 auto;" id="y">
<h6>I do align :)</h6>
</div>