How to get navbar to display as static top

Coreysan 1,811 Reputation points
2022-01-07T01:20:56.963+00:00

I'm a novice with navbar. I'm using bootstrap 4.3.1, and want to use the code I learned in a class to be static at the top.
I hope this doesn't get difficult! Can this be done with a minimum of work?

I attached the code because when I include it here, I get access denied.
162930-code-sample.txt

Any advice would be appreciated!

Developer technologies ASP.NET ASP.NET Core
0 comments No comments
{count} votes

Accepted answer
  1. Rebin Qadir 151 Reputation points Volunteer Moderator
    2022-01-09T21:07:38.907+00:00

    Add navbar-fixed-top class to fixed the navbar.

    <nav class="navbar navbar-expand-lg navbar-light text-center navbar-fixed-top">
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Coreysan 1,811 Reputation points
    2022-01-09T22:07:18.01+00:00

    Thank you for your suggestion. I am very puzzled why it didn't work. I even tried "navbar-static-top" and nothing works at all.

    I know that the <nav>div is wrapped with the <header> div.

    If I tweak the <header> div then I get some results, but I break other things. Right now there's no classes declared for <header>.

    Any thoughts?

    (This is using MVC Core)


  2. Coreysan 1,811 Reputation points
    2022-01-10T17:32:20.483+00:00

    This works:

    <header class="sticky-lg-top">

    But I hear that sticky-top isn't necessarily supported on other browsers.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.