If you inspect the div with text, you will see that it is larger than the anchor container. The font size is 1rem, the top and bottom margins of the div are both 0.5rem, which adds up to 2rem, which is set as the height of the anchor. Why is it not the full height?
nav {
display: flex;
flex-direction: row;
flex: 1;
}
nav a {
font-size: 2rem;
position: relative;
overflow: hidden;
height: 4rem;
padding: 0rem 0.5rem 0rem 0.5rem;
border: white 1px solid;
color: white;
text-decoration: none;
background-color: black;
transition: background-color 0.5s, color 0.5s, height 0.5s;
border-radius: 0.2rem;
}
nav a div {
margin: 1rem 0rem 1rem 0rem;
}
<nav>
<a>
<div>text</div>
</a>
</nav>