I'm trying to make a website with a navbar that sticks to the top of the screen. I followed the tutorial on w3schools, and while most of it works, it seems like the selector for finding the next element after the sticky class isn't working.

I don't know if it has to do with precedence, or if I wrote something wrong and it's just not finding anything, or what, but I've messed around with every parameter I could think of and commented out all the other styling for the affected items and nothing is working.

Even making a selector like ".sticky ~ *" does nothing. It's like once the sticky class is applied, it stops looking for other rules that might be affected by it. Moving the rules to the bottom, adding !important, nothing seems to work.

If someone better at CSS than me could figure out why it's not working, I'd appreciate it. I've been stuck on this for over an hour and I'm going nowhere. I hope the code is relatively easy to read.