I am working with a container that has a height of 100vh
to fill the entire screen. Inside this container, I have a h1
and a div
. I want to center align the content within the div
on the page, but the presence of the h1
is causing issues.
My current setup is as follows:
HTML:
<div class="main-container">
<h1>This is a headline</h1>
<div class="content-container">
<p>Different stuff in here</p>
</div>
</div>
And the CSS is:
.main-container {
display: grid;
height: 100vh;
align-content: center;
justify-content: center;
}
Currently, this setup centers the h1
and the content-container
together. However, I want to center the content with respect to the main-container
, so that it is always in the middle while the h1
remains a certain distance above. Is my only option to place the h1
tag inside the main-container
and make it absolute?