I am currently trying to get my Navbar affixed to the top of the page after I have scrolled past an image. I have tried following the solutions from How to Add Affix to Bootstrap Fixed Bottom Navbar and Adding a header image before navbar-fixed-top, however, I can't seem to get the Navbar to stay on the screen.
My HTML code is:
<nav class="navbar navbar-expand-sm bg-dark navbar-dark" data-spy="affix"
data-offset-top="50">
and my CSS is:
.affix {
top: 0;
width: 100%;
position: fixed;
}
.affix-top {
width: 100%;
}
Bootstrap and JQuery I have imported:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
Any help you can provide would be great
Thanks :)