I’m having problems with the last requirement “the navbar should always be at the top”. Out of desperation I googled and I found out the freeCodeCamps tutorial on how to make it stay at the top, and it was exactly what I had.
HTML:
<header id="header">
<nav id="navbar">
<ul>
<li><a class="nav-link" href="#welcome-section">Welcome</a></li>
<li><a class="nav-link" href="#projects">Projects</a></li>
<li><a class="nav-link" href="#Contact Me">Contact Me</a></li>
</nav>
</header>
CSS:
header {
margin-top: -1rem;
width: 100%;
position: fixed;
top: 0;
left: 0;
display: flex;
z-index: 10;
background-color: var(--light-color);
color: var(--dark-color);
padding: 0 1rem;
}
What’s the problem with this code? Position: fixed and having the id should be already enough for it to work, including top: 0;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Challenge: Personal Portfolio Webpage - Build a Personal Portfolio Webpage
Link to the challenge: