I can't figure out how to vertically center my name in this div. It's supposed to be the homepage on my website. The PgOne div is supposed to take up the height of the person's screen, so the name is supposed to be centered on the div (main), which is just below the navbar on PgOne.
The problem with the solutions that work is that when the window is really small vertically, it runs into the navbar.
I've tried these in CSS under .main and .name
flex-grow: 1;
display: flex;
align-items: center;
^^ This works, but when the window is really small vertically, it runs into the navbar.
transform: translate(-50%, -50%);
position: absolute;
^^This works, but when the window is really small, they overlap.
padding-top: 10%; padding-bottom: 10%;
^^ Doesn't work.
display: table-cell;
text-align: center;
vertical-align: middle;
^^ Doesn't work.
Here is my code:
<div class=PgOne>
<div class="navbar">
<div>
<p>HOME</p>
</div><div>
<p>ABOUT</p>
</div><div>
<p>EXPERIENCE</p>
</div><div>
<p>RESUME</p>
</div><div>
<p>CONTACT</p>
</div>
</div>
<div class=main>
<div class="name">
<p>FirstName<br>LastName</p>
</div>
</div>
</div>
CSS
.navbar div {
margin-top: 13px;
margin-right: 1%;
width: 18%;
font-size: 20px;
display: inline-block;
position: relative;
}
.main {
font-size: 25px;
margin: 0 auto;
text-align: center;
width: 50%;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
padding: 20px;
/*flex-grow: 1;
display: flex;
align-items: center;*/
}