问题描述
在引导程序3中,我希望所有屏幕尺寸的导航栏默认都处于折叠状态.
In bootstrap 3, I want the navbar to be collapsed by default for all screen sizes.
我在此处发现,Bootstrap 3首先是移动设备,其导航栏默认情况下是折叠"的,当达到一定的最小大小时会扩展".在那篇文章之后,我尝试使用 @ grid-float-breakpoint
来查找自定义CSS ,但我无处可去.请从这里引导我.
I have found here that Bootstrap 3 being mobile first, its navbar is "collapsed" by default and and "expands" when it reaches a certain minimum size.. Following that post, I tried messing around with @grid-float-breakpoint
for customized css, but I got nowhere. Please guide me from here.
推荐答案
您可以使用CSS覆盖 Bootstrap 3 的默认设置.例如,这会将导航栏设置为在屏幕宽度小于2000像素(可容纳大多数屏幕)时折叠..
You could use CSS to override the Bootstrap 3 defaults. For example, this would set the navbar to collapse on screen widths less than 2000 pixels (accommodating most screens)..
@media (max-width: 2000px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
演示: http://www.bootply.com/122572
Bootstrap 4(测试版)更新
在Bootstrap 4中,导航栏默认情况下总是折叠到移动/汉堡包版本中:演示. navbar-expand-*
类用于更改断点.
In Bootstrap 4 the navbar is always collapsed into the mobile/hamburger version by default: Demo. The navbar-expand-*
class are used to change the breakpoint.
这篇关于如何使Bootstrap 3导航栏在所有屏幕尺寸下均保持折叠状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!