简体   繁体   English

如何使Bootstrap 3导航栏不折叠

[英]How to make Bootstrap 3 navbar not collapsible

I've been searching a lot but still didn't find anything similar. 我已经搜索了很多,但仍然没有找到任何类似的东西。 If replace navbar-collapse with navbar I am getting the looks as if you've toggled the show collapsed menu items button. 如果将navbar-collapse替换为navbar我的外观就好像您已切换了Show折叠菜单项按钮。 I've also found questions how to decrease the breakpoint at which the navbar collapses, but it's not what I need. 我还发现了一些问题,如何减少导航栏折叠的断点,但这不是我所需要的。 What I need is to remove the collapsible menu generally. 我需要的是通常删除可折叠菜单。 Any idea? 任何想法?

Bootstrap is displaying collapsed elements because of the way responsive design works: The CSS code is written for the smallest viewport, and then using media queries, the design is progressively enhanced to render elements for each specific viewport. 由于响应式设计的工作方式,Bootstrap正在显示折叠的元素:为最小的视口编写CSS代码,然后使用媒体查询逐步增强设计以针对每个特定视口呈现元素。

Thus, the CSS code that is responsible for displaying the "normal" navbar (ie the navbar for a medium to large viewport) is wrapped around @media (min-width: 768px) . 因此,负责显示“普通”导航栏(即,中到大视口的导航栏)的CSS代码被包裹在@media (min-width: 768px)周围。 That means that as soon as your viewport goes under that value, the elements revert to their original design, which is the small viewport design. 这意味着只要您的视口低于该值,元素就会恢复为原始设计,即小视口设计。

If you do not want to change the breakpoints as proposed in this question , you have a few other solutions: 如果您不想按照此问题中的建议更改断点,则可以使用其他一些解决方案:

You can put the navbar links inside navbar-header , and then add some CSS to override the Bootstrap defaults.. 您可以将navbar链接放在navbar-header ,然后添加一些CSS来覆盖Bootstrap的默认设置。

.navbar-nav {
    margin:0;
}
.navbar-nav>li {
    float:none;
    display:inline-block;
}
.navbar-nav>li>a {
  padding-top: 15px;
  padding-bottom: 15px;
}

Demo: http://www.bootply.com/118426 演示: http//www.bootply.com/118426

Alternate (display scrollbar instead of wrapping): http://www.bootply.com/118304 备用(显示滚动条而不是换行): http : //www.bootply.com/118304

i am having this issue and i have just solved it 我有这个问题,我刚刚解决了

this will undo the collapse 这将消除崩溃

/* Undo the collapsing navbar */
.navbar-collapse {
    display: block !important;
    height: auto !important;
    padding-bottom: 0;
    overflow: visible !important;
    visibility: visible !important;
}
.navbar-toggle {
    display: none;
}
.navbar-collapse {
    border-top: 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM