我创建了一个带有大徽标图像的自定义高度导航栏,我确定我在CSS中遗漏了一些东西,因为当点击下拉菜单时,它会在页面上跳得更高,直到再次点击它为止,然后链接有效。
http://machadodesign.com/bootstrap/
有一个“有效”的例子这是我用于导航栏的CSS
@media (min-width: 992px) {
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
min-height: 85px;
bottom: 0 ;
}
}
.navbar-nav li a {
padding-top: 30px;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #333;
background-color: #e7e7e7;
}
.navbar-default .navbar-nav .active a {
background: #f8f8f8;
text-shadow: 0px 0px 9px rgba(144, 169, 210, 1) !important;
}
.dropdown .active {
text-shadow: 0px 0px 9px rgba(144, 169, 210, 1) !important;
}
.navbar-brand {
height: inherit;
padding: 5px 15px;
}
.navbar-brand a{
padding-top: 0 !important;
}
.navbar-brand img {
height: 50px
}
.dropdown li, .dropdown li:hover {
/* padding-top: 10px;*/
padding-bottom: 0px !important;
/* min-height: 40px;*/
}
.dropdown li a {
padding-top: 10px;
padding-bottom: 0px !important;
min-height: 40px;
}
.logo-tag {
font-size: 10px;
font-style: italic;
font-weight: 700;
line-height: 14px;
letter-spacing: 0.04em;
}
@media (min-width: 768px) {
.logo-tag {
font-size: 13px;
font-style: italic;
font-weight: 700;
line-height: 14px;
letter-spacing: 0.04em;
}
.navbar-brand img {
height: 58px
}
.navbar-brand {
height: inherit;
padding: 3px 15px;
}
}
这是我所拥有的导航栏的HTML。
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid social-bar hidden-xs">
<div class="container">
<div class="row">
<div class="col-sm-9">Questions? Need help? Call now: (866) 214-6128</div>
<div class="col-sm-3 text-right">
<ul class="list-inline">
<li><i class="fa fa-lg fa-facebook"></i></li>
<li><i class="fa fa-lg fa-twitter"></i></li>
<li><i class="fa fa-lg fa-google-plus"></i></li>
<li><i class="fa fa-lg fa-youtube"></i></li>
<li><i class="fa fa-lg fa-rss"></i></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" id="myNavbar" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#" class="navbar-brand"><img src="images/logo.png"><span class="logo-tag">Customer and Class Management Made Easy!</span></a>
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Features <span class="caret"></span></a>
<ul class="dropdown-menu navbar-right">
<li><a href="features.html">Features Overview</a></li>
<li><a href="easystart.html">Easy Startup!</a></li>
<li><a href="easyops.html">Easy to Use!</a></li>
<li><a href="customize.html">Easy to Customize!</a></li>
<li><a href="poweruser.html">Power-user Features</a></li>
<li><a href="country.html">Multi-country</a></li>
<li><a href="add-ons.html">Lots of Add-ons</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Try it Free <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="demo.html">Take a Test Drive</a></li>
<li><a href="signup.html">Get Started Today</a></li>
</ul>
</li>
<li><a href="pricing_US.html">Pricing</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><i class="fa fa-lock"></i> Login</a></li>
</ul>
</div>
</div>
</nav>
非常感谢任何帮助。
答案 0 :(得分:2)
问题就在您提供的CSS的顶部:
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
min-height: 85px;
bottom: 0 ;
}
如果它悬停在焦点上或焦点上,它只会保留其min-height
,这就是点击导致跳跃(触发焦点)的原因。将其更改为:
.navbar-default .navbar-nav > li > a {
min-height: 85px;
bottom: 0 ;
}