Bootstrap 3:可折叠菜单 z-Index
Bootstrap 3: Collapsable Menu's z-Index
我的测试站点在这个link...
当页面宽度低于 768px 时,如何让导航图标菜单正确显示在其他所有内容之上?
以下是我的导航栏和颜色导航栏 css 文件:
---开始navbar.css--
/* <nav> tag, classes: navbar & navbar-default */
.navbar{
display: block;
margin-bottom: 20px;
}
.navbar-default{
background:#317ca2;
background:-o-linear-gradient(top, #3f94bf, #246485);
background:-ms-linear-gradient(top, #3f94bf, #246485);
background:-moz-linear-gradient(top, #3f94bf, #246485);
background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #3f94bf), color-stop(1, #246485));
background:-webkit-linear-gradient(#3f94bf, #246485);
background:linear-gradient(top, #3f94bf, #246485);
-moz-box-shadow:0 1px 5px rgba(34,34,34,0.5);
-webkit-box-shadow:0 1px 5px rgba(34,34,34,0.5);
box-shadow:0 1px 5px rgba(34,34,34,0.5);
width:100%;
max-width:none;
height:50px;
margin:0;
padding:0;
border-bottom:1px solid #1b5572;
color: white;
display: block;
position: relative;
}
a.navbar-brand{
color: white;
}
/* <ul> tag, classes: nav & navbar-nav */
/* Collapsed menu links */
.navbar-default .navbar-nav > li > a {
color: white;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: yellow;
}
@media (max-width: 768px) {
.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.css--
谢谢!
更新代码后更新,只需在 navbar.css
中像这样更改 @media
@media (max-width: 767px) { /*-- Change max-width from 768 to 767 --*/
.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;
}*/ /*-- Disable this, suggest remove - this cause the menu disappear as soon as it toogle in --*/
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
position:relative; /*-- New attribute --*/
z-index:9999; /*-- New attribute --*/
background-color:#393939; /*-- New attribute --*/
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
}
希望对您有所帮助!
我的测试站点在这个link...
当页面宽度低于 768px 时,如何让导航图标菜单正确显示在其他所有内容之上?
以下是我的导航栏和颜色导航栏 css 文件:
---开始navbar.css--
/* <nav> tag, classes: navbar & navbar-default */
.navbar{
display: block;
margin-bottom: 20px;
}
.navbar-default{
background:#317ca2;
background:-o-linear-gradient(top, #3f94bf, #246485);
background:-ms-linear-gradient(top, #3f94bf, #246485);
background:-moz-linear-gradient(top, #3f94bf, #246485);
background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #3f94bf), color-stop(1, #246485));
background:-webkit-linear-gradient(#3f94bf, #246485);
background:linear-gradient(top, #3f94bf, #246485);
-moz-box-shadow:0 1px 5px rgba(34,34,34,0.5);
-webkit-box-shadow:0 1px 5px rgba(34,34,34,0.5);
box-shadow:0 1px 5px rgba(34,34,34,0.5);
width:100%;
max-width:none;
height:50px;
margin:0;
padding:0;
border-bottom:1px solid #1b5572;
color: white;
display: block;
position: relative;
}
a.navbar-brand{
color: white;
}
/* <ul> tag, classes: nav & navbar-nav */
/* Collapsed menu links */
.navbar-default .navbar-nav > li > a {
color: white;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: yellow;
}
@media (max-width: 768px) {
.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.css--
谢谢!
更新代码后更新,只需在 navbar.css
@media
@media (max-width: 767px) { /*-- Change max-width from 768 to 767 --*/
.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;
}*/ /*-- Disable this, suggest remove - this cause the menu disappear as soon as it toogle in --*/
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
position:relative; /*-- New attribute --*/
z-index:9999; /*-- New attribute --*/
background-color:#393939; /*-- New attribute --*/
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
}
希望对您有所帮助!