How to fix the overlapping navbar elements on small screen created using bootstrap?

846 Views Asked by At

Navbar brand name and button overlapping

Navbar brand name and button overlapping

This is ther desired result on small screen

This is ther desired result on small screen

navbar code

<nav class="navbar navbar-default micah-navbar-bg">
  <div class="navbar-header">
  <a class="navbar-brand navbar-brand-left" href="#"> <img src="/sites//cologo.png" alt="logo"></a><p style="display:inline-block;">Company name</p>
    <button id="quickLinksbtn" type="button" class="btn btn-danger ">QUICK LINKS</button>    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
  </div>
  <div class="navbar-collapse collapse">
    <ul class="nav navbar-nav">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#about">About</a></li>
      <li><a href="#contact">Contact</a></li>
    </ul>
    <div class="navbar-header navbar-right">
        <p class="navbar-text">
        <a href="#" class="navbar-link">Username</a>
        </p>
    </div>
  </div>
</nav>

Css for quick links

#quickLinksbtn{
position: absolute;
right: 100px;
margin-top: 45px;
border-radius: 0px;
}
1

There are 1 best solutions below

0
On

There is a confusion that I think might be happening. The"quick links" square is not going to be able to remain the same size, nor is the logo, nor is the nav-button.

This is why they are overlapping.

Personally: I would just build a mobile version of the site exactly how you want it to look on mobile and put it all in a div and have that div "display: none" on anything bigger than say 800px. And "display:block" on anything smaller than that.

Likewise your desktop nav section would be the opposite.

@media screen and (max-width: 800px) {
   .mobile-nav{display:block;}
   .desktopnav{display:none;}
}

@media screen and (min-width: 801px) {
   .mobile-nav{display:none;}
   .desktopnav{display:block;}
}