I'm making a portfolio website and I've run into an issue I need help with. It's a single page parallax site. When the user enters text appears saying welcome, the nav bar is out of site.
Once the user scrolls down to see the rest of my page the nav bar appears. I would like to nav bar to stay at the top of the page once the user scrolls down enough to the point where the nav bar gets to that position. Basically how this website does it http://findmatthew.com/.
I have tried wrapping the nav bar in a new div and using position: sticky, top: 0; but the styling of the nav bar disappears.
body {
margin: 0;
background: #222;
font-family: 'Work Sans', sans-serif;
font-weight: 800;
}
.container {
width: 80%;
margin: 0 auto;
}
header {
background: #1f2733;
margin-top: -22px; /* <<<--- This moves the entire nav box up or down!! */
}
header::after {
content: '';
display: table;
clear: both;
}
nav {
float: center;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
padding-top: 10px;
padding-bottom: 10px;
}
nav li {
display: inline-block;
margin-left: 190px;
position: relative;
font-family: 'Montserrat', sans-serif; /*Changing the font of the nav bar*/
}
nav a {
color: white;
text-decoration: none;
text-transform: uppercase;
font-size: 18px;
}
nav a:hover {
color: #a23131;
}
nav a::before {
content: '';
display: block;
height: 3px;
background-color: #a23131;
margin-top: -10px;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}