0
votes

I'd the Bootstrap 3 nav to collapse to hamburger menu at a different breakpoint to avoid it breaking onto a new line.

Currently: bad Desired:bad

I've tried pasting in the CSS solutions recommended in various answers from: Change Navbar breakpoint in Bootstrap 3.3.2 and Change bootstrap navbar collapse breakpoint without using LESS.

The top answer from first link above results in this:nogoog

Issues:

  • It looks like a deployed hamburger menu. I'm expecting a hamburger icon to click, like 'desired' image above.
  • The .navbar-right items ('Marketplace, cart icon, etc.) are right aligned, and outside of the menu. (See bottom right in above image)

body {
  background: #f0f0f0;
}

.navbar {
  border: none;
}

.dropdown-menu {
  background-color: #f5f5f5;
}

.navbar-header {
  background-color: #3a7dbb;
}
.collapse.navbar-collapse.js-navbar-collapse {
  background-color: #3a7dbb;
}

.navbar-default .navbar-nav > li > a.dropdown-toggle {
  font-family: "Oswald",Helvetica,Arial,sans-serif;
  font-size: 18px;
  color: white;
}

.dropdown > .dropdown-menu > li > a {
  font-size: 16px;
}

.glyphicon-shopping-cart:before {
  color: white;
}

.navbar .navbar-brand {
  padding-top: 0px;
}

.navbar .navbar-brand > img{
  height: 100%;
}

.dropdown > .dropdown-menu > li > a:hover {
  background-color: white;
}

.navbar-nav > li > .dropdown-menu {
  background-color: #f5f5f5;
  margin-top: 20px;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.navbar-default .navbar-nav > li > a {
  /*   width: 8em; */
  font-weight: bold;
}

.mega-dropdown {
  position: static !important;
  width: 100%;
}

.mega-dropdown-menu {
  padding: 20px 0px;
  width: 100%;
  box-shadow: none;
  -webkit-box-shadow: none;
}

.center {
  margin: auto;
}

.mega-dropdown-menu > li > ul {
  padding: 0;
  margin: 0;
}

.mega-dropdown-menu > li > ul > li {
  list-style: none;
}

.mega-dropdown-menu > li > ul > li > a {
  display: block;
  padding: 3px 20px;
  clear: both;
  font-weight: normal;
  line-height: 1.428571429;
  color: #262626;
  white-space: normal;
}

.mega-dropdown-menu > li ul > li > a {
  font-size: 16px;
}

.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
  text-decoration: none;
  color: #444;
  background-color: white;
}

li.dropdown:hover {
  background-color: #c3c1c1;
}

ul.dropdown-menu.mega-dropdown-menu.row {
  width: 80%;
  left: 0;
  right: 0;
  margin: 0 auto; /* Centers the element */
}

.mega-dropdown-menu .dropdown-header {
  color: #428bca;
  font-size: 18px;
  font-weight: bold;
}

.mega-dropdown-menu .dropdown-header > a {
  color: #428bca;
  font-size: 18px;
  font-weight: bold;
  padding-left: 0;
}

.mega-dropdown-menu form {
  margin: 3px 20px;
}

.mega-dropdown-menu .form-group {
  margin-bottom: 3px;
}

.navbar-default .navbar-nav .open .dropdown-menu > li > a {
  color: black !important;
}

/* .mega-dropdown-menu:before {
  content: "";
  border-bottom: 15px solid #fff;
  border-right: 17px solid transparent;
  border-left: 17px solid transparent;
  position: absolute;
  top: -15px;
  left: 285px;
  z-index: 10;
}

.mega-dropdown-menu:after {
  content: "";
  border-bottom: 17px solid #ccc;
  border-right: 19px solid transparent;
  border-left: 19px solid transparent;
  position: absolute;
  top: -17px;
  left: 283px;
  z-index: 8;
} */

.dropdown:hover .dropdown-menu {
  display: block;
  margin-top: 0; // remove the gap so it doesnt close
}
#main_pnlSiteTemplateHeader {
  background-color: white;
  padding-left: 0px;
  padding-right: 0px;
}
#main_content_Content {
  padding-top: 80px;
}
#main_content_TopBanner {
  padding-top: 80px;
}

ul.dropdown-menu.mega-dropdown-menu.row {
  top: 49px;
}

@media only screen and (min-width: 768px) {
  .dropdown:hover > .dropdown-menu {
    display: block;
  }

  .dropdown > .dropdown-toggle:active {
    pointer-events: none;
  }
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald|Open+Sans:400,400italic,600italic,600">
<!------ Include the above in your HEAD tag ---------->
<div class="">
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="navbar-header">
      <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				  </button>
      <a class="navbar-brand" href="#"><img src="http://www.hibarnsley.com/wp-content/uploads/2017/06/dummy-logo.png"></a>
    </div>
    <div class="collapse navbar-collapse js-navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">About<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
            <li class="col-sm-4">
              <ul>
                <li class="dropdown-header"><a href="#">Business Relationship Management</a></li>
                <li><a href="#">Capability</a></li>
                <li><a href="#">Role</a></li>
                <li><a href="#">Discipline</a></li>
                <li><a href="#">Philosophy</a></li>
              </ul>
            </li>
            <li class="col-sm-4">
              <ul>
                <li class="dropdown-header"><a href="#">Institute</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Policies</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Registered Providers</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Strategic Alliances</a></li>
              </ul>
            </li>
            <li class="col-sm-4">
              <ul>
                <li class="dropdown-header"><a href="#">Member-Based Leadership</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Board of Directors</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Knowledge Team</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Executive Council</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Council</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Regional Ambassadors</a></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
      
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Resources<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
        </li>
        </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Learning<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Programs<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">

          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Career<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">

          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Membership<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
          </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown"><a class="dropdown-toggle" href="#">Marketplace<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="/books">Publications</a></li>
            <li><a href="/memberships">Memberships</a></li>
            <li><a href="/events">Events</a></li>
            <li class="divider"></li>
            <li><a href="/brm-marketplace">Full Marketplace</a></li>
          </ul>
        </li>
        <li><a href="/brm-cart"><span class="glyphicon glyphicon-shopping-cart"></span></a></li>
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-question-sign"></span><span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">FAQs</a></li>
            <li><a href="#">Intellectual Property Request</a></li>
            <li><a href="#">Contact BRM Institute</a></li>
          </ul>
        </li>
        <ul class="nav navbar-nav">
          <li class="dropdown mega-dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> Sign Up</a>
          </li>
        </ul>
        <ul class="nav navbar-nav">
          <li class="dropdown mega-dropdown">
            <a href="http://brmi.mpxstage.com/account/login.aspx" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-log-in"></span> Login</a>
          </li>
        </ul>
      </ul>
    </div>
  </nav>
</div>

Thank you!

2

2 Answers

1
votes

The cleanest solution to your problem is to customize bootstrap library as per your requirement. In bootstrap 3.3, it is possible. Refer this link https://getbootstrap.com/docs/3.4/customize/. Refer variable "@grid-float-breakpoint"(Point at which the navbar becomes uncollapsed). The Default value set for it is "@screen-sm-min", modify it as per your requirement like "@screen-lg-min". Compile and download the bootstrap library and include it in your index.html. It will solve your all issues in the cleanest way.

0
votes

please try this code

<!DOCTYPE html>
<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald|Open+Sans:400,400italic,600italic,600">
<style>


body {
  background: #f0f0f0;
}

.navbar {
  border: none;
}

.dropdown-menu {
  background-color: #f5f5f5;
}

.navbar-header {
  background-color: #3a7dbb;
}
.collapse.navbar-collapse.js-navbar-collapse {
  background-color: #3a7dbb;
}

.navbar-default .navbar-nav > li > a.dropdown-toggle {
  font-family: "Oswald",Helvetica,Arial,sans-serif;
  font-size: 18px;
  color: white;
}

.dropdown > .dropdown-menu > li > a {
  font-size: 16px;
}

.glyphicon-shopping-cart:before {
  color: white;
}

.navbar .navbar-brand {
  padding-top: 0px;
}

.navbar .navbar-brand > img{
  height: 100%;
}

.dropdown > .dropdown-menu > li > a:hover {
  background-color: white;
}

.navbar-nav > li > .dropdown-menu {
  background-color: #f5f5f5;
  margin-top: 20px;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.navbar-default .navbar-nav > li > a {
  /*   width: 8em; */
  font-weight: bold;
}

.mega-dropdown {
  position: static !important;
  width: 100%;
}

.mega-dropdown-menu {
  padding: 20px 0px;
  width: 100%;
  box-shadow: none;
  -webkit-box-shadow: none;
}

.center {
  margin: auto;
}

.mega-dropdown-menu > li > ul {
  padding: 0;
  margin: 0;
}

.mega-dropdown-menu > li > ul > li {
  list-style: none;
}

.mega-dropdown-menu > li > ul > li > a {
  display: block;
  padding: 3px 20px;
  clear: both;
  font-weight: normal;
  line-height: 1.428571429;
  color: #262626;
  white-space: normal;
}

.mega-dropdown-menu > li ul > li > a {
  font-size: 16px;
}

.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
  text-decoration: none;
  color: #444;
  background-color: white;
}

li.dropdown:hover {
  background-color: #c3c1c1;
}

ul.dropdown-menu.mega-dropdown-menu.row {
  width: 80%;
  left: 0;
  right: 0;
  margin: 0 auto; /* Centers the element */
}

.mega-dropdown-menu .dropdown-header {
  color: #428bca;
  font-size: 18px;
  font-weight: bold;
}

.mega-dropdown-menu .dropdown-header > a {
  color: #428bca;
  font-size: 18px;
  font-weight: bold;
  padding-left: 0;
}

.mega-dropdown-menu form {
  margin: 3px 20px;
}

.mega-dropdown-menu .form-group {
  margin-bottom: 3px;
}

.navbar-default .navbar-nav .open .dropdown-menu > li > a {
  color: black !important;
}

/* .mega-dropdown-menu:before {
  content: "";
  border-bottom: 15px solid #fff;
  border-right: 17px solid transparent;
  border-left: 17px solid transparent;
  position: absolute;
  top: -15px;
  left: 285px;
  z-index: 10;
}

.mega-dropdown-menu:after {
  content: "";
  border-bottom: 17px solid #ccc;
  border-right: 19px solid transparent;
  border-left: 19px solid transparent;
  position: absolute;
  top: -17px;
  left: 283px;
  z-index: 8;
} */

.dropdown:hover .dropdown-menu {
  display: block;
  margin-top: 0; // remove the gap so it doesnt close
}
#main_pnlSiteTemplateHeader {
  background-color: white;
  padding-left: 0px;
  padding-right: 0px;
}
#main_content_Content {
  padding-top: 80px;
}
#main_content_TopBanner {
  padding-top: 80px;
}

ul.dropdown-menu.mega-dropdown-menu.row {
  top: 49px;
}
@media (max-width: 1126px){
  .navbar-nav{
    width: 100%;
  }
  .navbar-toggle {
      display: block;
  }
  .navbar-header{
    width: 100%;
  }
  .navbar{
    min-height: 50px;
  }

  .navbar-collapse.collapse.in {
      display: block !important;
      visibility: visible !important;
      overflow-y: auto;
  }
  .navbar-collapse.collapse {
      display: none!important;
      height: auto!important;      
      max-height: none;
      padding-bottom: 0;
      visibility: visible!important;
  }
}
@media only screen and (min-width: 768px) {
  .dropdown:hover > .dropdown-menu {
    display: block;
  }

  .dropdown > .dropdown-toggle:active {
    pointer-events: none;
  }
}
</style>
</head>
<body>

<!------ Include the above in your HEAD tag ---------->
<div class="">
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="navbar-header">
      <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          </button>
      <a class="navbar-brand" href="#"><img src="http://www.hibarnsley.com/wp-content/uploads/2017/06/dummy-logo.png"></a>
    </div>
    <div class="collapse navbar-collapse js-navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">About<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
            <li class="col-sm-4">
              <ul>
                <li class="dropdown-header"><a href="#">Business Relationship Management</a></li>
                <li><a href="#">Capability</a></li>
                <li><a href="#">Role</a></li>
                <li><a href="#">Discipline</a></li>
                <li><a href="#">Philosophy</a></li>
              </ul>
            </li>
            <li class="col-sm-4">
              <ul>
                <li class="dropdown-header"><a href="#">Institute</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Policies</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Registered Providers</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Strategic Alliances</a></li>
              </ul>
            </li>
            <li class="col-sm-4">
              <ul>
                <li class="dropdown-header"><a href="#">Member-Based Leadership</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Board of Directors</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Knowledge Team</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Executive Council</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Council</a></li>
                <li class="divider"></li>
                <li class="dropdown-header"><a href="#">Regional Ambassadors</a></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Resources<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
        </li>
        </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Learning<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Programs<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">

          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Career<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">

          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav">
        <li class="dropdown mega-dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Membership<span class="caret"></span></a>
          <ul class="dropdown-menu mega-dropdown-menu row">
          </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown"><a class="dropdown-toggle" href="#">Marketplace<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="/books">Publications</a></li>
            <li><a href="/memberships">Memberships</a></li>
            <li><a href="/events">Events</a></li>
            <li class="divider"></li>
            <li><a href="/brm-marketplace">Full Marketplace</a></li>
          </ul>
        </li>
        <li><a href="/brm-cart"><span class="glyphicon glyphicon-shopping-cart"></span></a></li>
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-question-sign"></span><span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">FAQs</a></li>
            <li><a href="#">Intellectual Property Request</a></li>
            <li><a href="#">Contact BRM Institute</a></li>
          </ul>
        </li>
        <ul class="nav navbar-nav">
          <li class="dropdown mega-dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> Sign Up</a>
          </li>
        </ul>
        <ul class="nav navbar-nav">
          <li class="dropdown mega-dropdown">
            <a href="http://brmi.mpxstage.com/account/login.aspx" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-log-in"></span> Login</a>
          </li>
        </ul>
      </ul>
    </div>
  </nav>
</div>

</body>
</html>