I'm new to HTML and CSS and I need to implement a Sticky navbar but when I transform it into position fixed it messes up my code and it does not show the animated background I put in how do I fix it ?
This is my CSS
body {
margin: 0;
padding: 0;
background: linear-gradient(90deg, #111e6c, teal, #135589);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
/*********************Nav bar animation and design*************************/
#navbar {
background-color: rgba(0, 0, 0, 0.376);
width: 100vw;
display: flex;
justify-content: space-evenly;
align-items: center;
position: fixed;
}
.navbar-index{
width:100%;
}
.nav-link {
font-family: fantasy;
color: white;
font-size: 25px;
height: 42px;
border: 2px solid black;
text-align: center;
flex-grow: 1;
}
This is the HTML
<body>
<div class="container">
<nav class="navbar-index" id="navbar">
<a href="/Index.html" class="nav-link link-1">Home</a>
<a href="/About.html" class="nav-link link-1">About</a>
<a href="/Contact.html" class="nav-link link-1">Contact</a>
</nav>
</div>
</body>
</html>