我的导航栏设置如下:(注意课程为navbar navbar-default
)
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-global">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar-global">
<ul class="nav navbar-nav topnav">
....
这很好用,我在屏幕右侧显示三明治菜单。
我希望能够为navbar
应用相同的CSS行为,但不能使用navbar-default
类。但如果我这样做:
<nav class="navbar" role="navigation">
我的三明治菜单根本没有显示。
如何解决这个问题?
答案 0 :(得分:1)
只需将以下 css 粘贴到自定义css文件中,该文件位于引导程序css文件的正下方
.navbar {
background-color: #f8f8f8;
border-color: #e7e7e7;
}
.navbar .navbar-toggle {
border-color: #ddd;
}
.navbar .navbar-toggle .icon-bar {
background-color: #888;
}
.navbar .navbar-collapse {
border-color: #e7e7e7;
}
.navbar {
background-color: #f8f8f8;
border-color: #e7e7e7;
}
.navbar .navbar-toggle {
border-color: #ddd;
}
.navbar .navbar-toggle .icon-bar {
background-color: #888;
}
.navbar .navbar-collapse {
border-color: #e7e7e7;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<nav class="navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-global">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar-global">
<ul class="nav navbar-nav topnav"></ul>
</div>
</nav>
答案 1 :(得分:1)
当您添加类navbar-default:
时,Bootstrap会为切换菜单添加背景颜色.navbar-default .navbar-toggle .icon-bar {
background-color: #888;
}
删除课程时,没有应用背景颜色,因此您需要自己添加
.navbar-toggle .icon-bar {
// background-color:*****;
}