Bootstrap 3 - 显示所有屏幕尺寸的折叠导航 [英] Bootstrap 3 - show collapsed navigation for all screen sizes
问题描述
我使用的是 Bootstrap v3.
I am using Bootstrap v3.
我有导航栏类,这样当我的屏幕移动大小时,导航会折叠并出现类似网格的小切换按钮 - 所以这按预期工作.
I have the navbar classes in place so that when I have my screen mobile-size the navigation collapses and the little grid-like toggle button appears - so this is working as expected.
我想要的是,这是所有屏幕尺寸的默认操作.也就是说,即使在桌面上,我也希望导航折叠起来并且切换按钮可见.
what i would like, is for this to be the default action for all screen sizes. That is, even on a desktop I would like the navigation to be collapsed and the toggle button to be visible.
我已经浏览了 css,有一大堆东西提供了功能,但我不知道要更改哪些部分.
I've had a look through the css and there is a whole bunch of stuff that provides the functionality, though I don't know which parts to change.
我试过注释掉较大的媒体查询,尽管它们很多,而且似乎对其他样式有连锁反应.
I've tried commenting out the larger media-queries, though there are a lot of them and it seems to have a knock-on effect to other styling.
有什么想法吗?
推荐答案
你可以像这样使用覆盖默认的 Bootstrap CSS...
You can use override the default Bootstrap CSS like this...
.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;
}
演示:http://www.bootply.com/114896
这将通过覆盖 Bootstrap @media 查询来确保始终使用折叠的导航栏.
This will ensure that the collapsed navbar is always used by overriding the Bootstrap @media queries.
更新:对于 Bootstrap 4,您只需要删除 navbar-toggleable
类:http://www.codeply.com/go/LN6szcJO53
Update: For Bootstrap 4, you just need to remove the navbar-toggleable
class:
http://www.codeply.com/go/LN6szcJO53
这篇关于Bootstrap 3 - 显示所有屏幕尺寸的折叠导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!