I have some troubles with the content inside header, which I want to center vertically and horizontally.
I’ve tried to add align-items: center; and justify-content: center; into header section in my CSS file, but it doesn’t work. I don’t know why - I think it should work, because I set body as display: flex;.
If anyone could help, I will be extremely grateful.
Remove the display:flex from the body. It isn’t doing anything for you (the page already flows down in a column. ).
Instead, restructure your header css to something like this:
header {
background-color: #1C344C;
padding: 2rem; /* give it a little space */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
display:flex only applies to immediate children of the tag flex is attached to. It doesn’t cascade and inherit.