Tell us what’s happening:
I have some nav-links in this navbar. I’d like the link elements to fill the navbar vertically, so that they were easier to click. When I have “height: 100%” it does fill vertically, but then the text stays at the top of the element, which is not as visually appealing. Ideally I’d like a fix that works even if I adjust the height of the navbar.
I’ve tried “vertical-align: middle;” but it isn’t working for some reason.
Are there any easy solutions to this? Thank you for your time ;_;
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Portfolio</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav id="navbar">
<header></header>
<a id="nav-link" class="nav-link" href="#about">About</a>
<a id="nav-link" class="nav-link" href="#video">Video</a>
<a id="nav-link" class="nav-link" href="#credits">Credits</a>
<a id="nav-link" class="nav-link" href="#email">Email</a>
</nav>
</body>
/* file: styles.css */
* {
box-sizing: border-box;
margin: 0;
}
#navbar {
background-color: powderblue;
display: grid;
grid-auto-flow: column;
grid-template-columns: 5fr 1fr 1fr 1fr 1fr;
text-align: center;
align-items: center;
height: 50px;
}
#nav-link {
color: white;
background-color: gray;
text-decoration: none;
text-align: center;
align-items: center;
font-size: 1.2rem;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Personal Portfolio Webpage - Build a Personal Portfolio Webpage
Link to the challenge: