According to the documentation of the Bootstrap 3's navbar static-top,
Static top Create a full-width navbar that scrolls away with the page by adding .navbar-static-top and include a .container or .container-fluid to center and pad navbar content.
Unlike the .navbar-fixed-* classes, you do not need to change any padding on the body.
what does this method do? The above documentation looks like to me that the navbar is fixed at the top of the screen even when I scroll down the page to the bottom. However, it's what .navbar-fixed-top
does, and when I used .navbar-fixed-top
in my app, it works exactly what I've mentioned.
However, when I wrote .navbar-static-top
in my app, I don't know what makes it different from just the .navbar-default
. Anyone can help me in clarifying the difference and what the .navbar-static-top
do?
To create a fixed top menu, use position:fixed and top:0 .
The navbar-header is mostly an architectural class for Bootstrap navbar. It allocates approximately 150px to the left of the navbar to wrap the navbar-brand and allow the brand name or logo to make use of the entire area on click or hover.
Use the . navbar-text class to vertical align any elements inside the navbar that are not links (ensures proper padding and text color).
navbar-static-top
removes the left,right and top border created by navbar-default
so that it looks better at the top of the page, whereas you might want to use just navbar-default
elsewhere on the page...
On the other hand, navbar-fixed-top
uses position:fixed
. If there is content on the page that extends below the viewport (as there is on most pages) the navbar-fixed-top
will remain stuck to the top, whereas the navbar-static-top
will scroll away. Since the navbar-fixed-top
is fixed, it requires the body to have padding-top so that it doesn't overlay page content...
As you can see when you scroll down in each example the top navbar responds differently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With