我是网站设计的新手,遇到了一个我似乎无法找到解决方案的问题。我创建一个网站和我想要的下拉菜单居中,并跨越100%的屏幕。我有菜单工作,但是当我点击下拉菜单时,切换按钮也会跨越到与实际下拉菜单相同的宽度,导致所有其他导航元素被推到右侧。
当您点击导航栏中的下拉菜单时,您可以在http://cheekylildevils.co.uk看到我的意思。
提前致谢
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<ul class="nav nav-pills">
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">About Us <b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li class="dropdown-submenu">
<a href="#">More options</a>
<a href="#">More options</a>
<a href="#">More options</a>
<a href="#">More options</a>
<a href="#">More options</a>
<a href="#">More options</a>
</li>
</ul>
</li>
</ul>
<li><a href="#">Key Info</a></li>
<li><a href="#">Learning</a></li>
<li><a href="#">Children</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
</nav>
的CSS:
.nav {
display: inline-block;
}
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
text-align: center;
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.nav-pills>li {
float: none;
}
.nav-pills>li>a {
color: #fff;
}
.nav-pills>li>a:hover {
background: none;
}
.nav .open>a, .nav .open>a:hover {
background: none!important;
border: none!important;
}
.navbar-collapse.collapse {
display: none!important;
background-color: rgba(3, 3, 3, 0.63);
}
.navbar-nav {
float: none!important;
margin-top: 0px;
width: 60%;
margin: 0 auto;
}
.navbar-nav>li {
text-align: center;
display: inline-block;
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
.navbar-inverse {
background-color: #c31f40;
border-color: #d82a4d;
}
.open>.dropdown-menu {
display: inline-block;
width: 100%;
position: static;
background: none;
color: #fff;
}
.dropdown-menu>li>a {
color: #fff;
display: inline-block;
}