如果我的导航栏和下拉项之间存在这么小的透明差距,我很难找到来源。它杀了我。任何人都可以帮助我找到并删除它吗?
我的HTML
<!-- Static navbar -->
<nav id="custom-bootstrap-menu" class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div id="navlogo">
<a class="navbar-brand" href="#">CHEEZ-IT!</a>
</div>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About Us <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Who are Cheez-it's</a></li>
<li><a href="#">Credentials</a></li>
</ul>
</li>
<li><a href="#contact">Our Services</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Industries <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Cheeze-it Solar</a></li>
<li><a href="#">Cheeze-it Infrastructure</a></li>
<li><a href="#">Cheeze-it Harvest</a></li>
</ul>
</li>
<li><a href="#contact">Partners</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
这是我的CSS,但我认为这不会导致它。
#custom-bootstrap-menu.navbar-default .navbar-brand {
color: #fbb216;
}
#custom-bootstrap-menu.navbar-default {
font-size: 14px;
background-color: rgba(13, 65, 103, 1);
border-width: 0px;
border-radius: 0px;
}
#custom-bootstrap-menu.navbar-default .navbar-nav>li>a {
color: rgba(255, 255, 255, 1);
background-color: rgba(13, 65, 103, 1);
}
#custom-bootstrap-menu.navbar-default .navbar-nav>li>a:hover,
#custom-bootstrap-menu.navbar-default .navbar-nav>li>a:focus {
color: rgba(13, 65, 103, 1);
background-color: rgba(255, 255, 255, 1);
}
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a,
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a:hover,
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a:focus {
color: rgba(13, 65, 103, 1);
background-color: rgba(255, 255, 255, 1);
}
#custom-bootstrap-menu.navbar-default .navbar-toggle {
border-color: #ffffff;
}
#custom-bootstrap-menu.navbar-default .navbar-toggle:hover,
#custom-bootstrap-menu.navbar-default .navbar-toggle:focus {
background-color: #ffffff;
}
#custom-bootstrap-menu.navbar-default .navbar-toggle .icon-bar {
background-color: #ffffff;
}
#custom-bootstrap-menu.navbar-default .navbar-toggle:hover .icon-bar,
#custom-bootstrap-menu.navbar-default .navbar-toggle:focus .icon-bar {
background-color: #ffffff;
}
感谢任何帮助!感谢
答案 0 :(得分:2)
此规则(border-width: 0px;
)导致了这一差距。
您可以添加与navbar
颜色相同的底部边框(或者您可以将dropdown-menu
类的边距减少1个像素,但自{{{{{{{{ 1}}与dropdown-menu
触发器不完全一致。
有保证金的替代方法
dropdown
底部边界方法:参见工作示例
@media (min-width: 768px) {
#custom-bootstrap-menu.navbar-default .dropdown-menu {
border: none;
margin-top: -1px;
}
}
&#13;
html {
background-color: red;
}
#custom-bootstrap-menu.navbar-default .navbar-brand {
color: #fbb216;
}
#custom-bootstrap-menu.navbar-default {
font-size: 14px;
background-color: rgba(13, 65, 103, 1);
border: none;
border-bottom: 1px solid rgba(13, 65, 103, 1);
border-radius: 0px;
}
#custom-bootstrap-menu.navbar-default .navbar-nav > li > a {
color: rgba(255, 255, 255, 1);
background-color: rgba(13, 65, 103, 1);
}
#custom-bootstrap-menu.navbar-default .navbar-nav > li > a:hover,
#custom-bootstrap-menu.navbar-default .navbar-nav > li > a:focus {
color: rgba(13, 65, 103, 1);
background-color: rgba(255, 255, 255, 1);
}
#custom-bootstrap-menu.navbar-default .navbar-nav > .active > a,
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a:hover,
#custom-bootstrap-menu.navbar-default .navbar-nav>.active>a:focus {
color: rgba(13, 65, 103, 1);
background-color: rgba(255, 255, 255, 1);
}
#custom-bootstrap-menu.navbar-default .navbar-toggle {
border-color: #ffffff;
}
#custom-bootstrap-menu.navbar-default .navbar-toggle:hover,
#custom-bootstrap-menu.navbar-default .navbar-toggle:focus {
background-color: #ffffff;
}
#custom-bootstrap-menu.navbar-default .navbar-toggle .icon-bar {
background-color: #ffffff;
}
#custom-bootstrap-menu.navbar-default .navbar-toggle:hover .icon-bar,
#custom-bootstrap-menu.navbar-default .navbar-toggle:focus .icon-bar {
background-color: #ffffff;
}
&#13;