question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Odd placements in a fixed-top navbar within a container, XS screens

See original GitHub issue

Using Bootstrap 4, Alpha 6

I’m using a fixed-top navbar, with the contents placed within a container to center. I noticed that the placement is off on XS screen sizes.

Following the directions form the Navbar docs:

Although it’s not required, you can wrap a navbar in a .container to center it on a page or add one within to only center the contents of a fixed or static top navbar.

In my attached sample code, I’m using the boilerplate navbar, with fixed-top class added, and contents placed within a container. I believe this is correct.

The issue, Bootstrap 4 on XS screen: bootstrap_4_xs

Working properly on Bootstrap 4 on SM screen: bootstrap_4_sm

Working properly in Bootstrap 3 on XS screen: bootstrap_3_xs

What changes on the drop down from XS to SM:

  • The width of the container (540px) is removed.
  • margin-left: auto and margin-right: auto are applied

This causes the container to shrink to only contain the brand logo. Because the toggler is placement: absolute relative to .container, it moves to a weird placement next to the logo in the smaller container.

My Workaround

@media (max-width: 575px) {
  .navbar {
     .container {
      margin-left: 0px;
      margin-right: 0px;
    }
  }
}

Zip file contains an example in Bootstrap 4 and a working example in Bootstrap 3 html_files.zip

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gijsbotjecommented, Jul 12, 2017

see #23056 (posted 4 hours ago) and the staging docs for more current codebase up to date docs https://twbs.github.io/staging/docs/4.0/examples/navbar-top-fixed/

0reactions
alexandre1985commented, Aug 28, 2017

This can be fixed with

@media (max-width: 991px) {
  .navbar-expand-lg .container {
    max-width: 100%;
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

navbar-fixed-top - page flickers and I am forced to top
I am using Bootstrap 3, navbar-fixed-top class in particular. I have two menus that I fix to top with JQ as shown below....
Read more >
Navbar
Use our position utilities to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to...
Read more >
"The Notch" and CSS | CSS-Tricks
This means that if you have a header bar that is a fixed position element with top: 0, it will initially render 20px...
Read more >
How to create an awesome navigation bar with HTML & CSS
A tutorial that takes a look at how to create a nice looking nav bar with a cool little hover effect for the...
Read more >
https://miller-motte.ancoraed.com/Content/bootstra...
... -radius.less","less/input-groups.less","less/navs.less","less/navbar.less" ... max-height: 340px;\n overflow-y: scroll;\n}\n.container {\n margin-right: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found