Skip to main content
Participant
August 29, 2022
Question

Navbar isn't positioned at the very top of the web

  • August 29, 2022
  • 4 replies
  • 234 views

I'm trying to place the navbar at the very top, it was working fine till I changed some of the other texts margin values and that seemed to have changed the navbar itself so now it has this very annoying gap at the top. I haven't found a way to fix it yet despite reverting the values and now it's stuck like this. Please help ASAP.

    This topic has been closed for replies.

    4 replies

    Nancy OShea
    Community Expert
    Community Expert
    August 30, 2022

    Try adding fixed-top class to the first line of your navbar code, like this:

     

    <nav class="navbar navbar-expand-md bg-light navbar-light fixed-top">

     

    Nancy O'Shea— Product User & Community Expert
    Jon Fritz
    Community Expert
    Community Expert
    August 30, 2022

    Looks like collapsing margins to me.

    Without seeing the code, it's impossible to say, however, collapsing margins between a parent and child element would cause exactly what you're seeing.

    This page explains what it is and how to fix it better than I could here: https://www.sitepoint.com/collapsing-margins/ 


    Nancy OShea
    Community Expert
    Community Expert
    August 29, 2022

    Anwers to layout questions are contained in your CODE not screenshots.

    Your local computer is not a publicly accessible website.

    Upload your site to a public server that you control. Post the URL here so we can see your online site.   If you don't have web hosting yet, get some.

     

     

     

     

    Nancy O'Shea— Product User & Community Expert
    Community Expert
    August 29, 2022

    What does it look like in your browser? The same as what you are seeing?  Are you able to share a link to the page so we can examine the code?  If not, most we can say is that something happened to your code and best thing to do would be to compare against the bootstrap sticky header navbar if that is what you are going for: https://getbootstrap.com/docs/5.2/examples/navbar-fixed/ 

    Participant
    August 29, 2022

    http://127.0.0.1:51964/preview/app/index.html

    Sure, heres the link to the page

    Community Expert
    August 29, 2022

    That's localhost meaning your own computer.  We need to see the page published somewhere online.