Nato522 Nato522 - 4 months ago 12
CSS Question

Bootstrap nav bar menu goes out when breakpoint is changed

I changed the breakpoint for the bootstrap navbar using this code:

@media (max-width: 1000px) {
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar-text {
float: none;
margin: 15px 0;
}
/* since 3.1.0 */
.navbar-collapse.collapse.in {
display: block!important;
overflow-y: auto;
}
.collapsing {
overflow: hidden!important;
}
.navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
}


My problem is that between 768px and the new breakpoint, the menu goes out of the nav container, and i want it to behave like in mobile (stay inside container and add a vertical scroll bar). I may be mising some css but no idea what :(

EDIT: Here you have the jsfiddle https://jsfiddle.net/nato522/e71e8bfd/

EDIT2: also, a picture to show the problem
navbar issue

Answer

Try This CSS:

@media (max-width: 1000px) {
.navbar-header {
    float: none;
}
.navbar-toggle {
    display: block;
}
.navbar-collapse {
    border-top: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-collapse.collapse {
    display: none!important;
}
.navbar-nav {
    float: none!important;
    margin: 7.5px -15px;
}
.navbar-nav>li {
    float: none;
}
.navbar-nav>li>a {
    padding-top: 10px;
    padding-bottom: 10px;
}
.navbar-text {
    float: none;
    margin: 15px 0;
}
/* since 3.1.0 */
.navbar-collapse.collapse.in {
    display: block!important;
    overflow-y: auto!important;
    overflow-x: hidden!important;
}
.collapsing {
    overflow: hidden!important;
}
.navbar-nav .open .dropdown-menu {
  position: static;
  float: none;
  width: auto;
  margin-top: 0;
  background-color: transparent;
  border: 0;
  -webkit-box-shadow: none;
  box-shadow: none;
}}
Comments