我正在尝试将我找到here的导航动画之一添加到我的引导程序导航中。 添加课程没有用,也没有更改导航栏css所以我需要一些帮助。
导航HTML:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index-en.html"><img class = "logo" src = "logo.png" alt = ""></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a class = "active" href="#">Home</a></li>
<li><a href="about.html">About us</a></li>
<li><a href="employees.html">Employees</a></li>
<li><a href="where.html">Where we are</a></li>
<li><div class="btn-group">
<a href="index.html" class="btn btn-default"><img src="img/hr.png" alt="" title = "Hrvatski" > </a>
</div></li>
</ul>
</div>
</div><!--/.nav-collapse -->
</div>
目前相关的CSS:
.navbar-default .navbar-nav > li > a {
color: #4E4F51!important;
text-transform: uppercase!important;
font-size: 15px;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #3BB34A!important;
background-color: transparent!important;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #3AB44A!important;
background-color: transparent!important;
}
那么如何将上述链接中的一个动画实现到我的导航栏?
答案 0 :(得分:0)
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index-en.html"><img class = "logo" src = "logo.png" alt = ""></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right pullDown">
<li class="active"><a class = "active" href="#">Home</a></li>
<li><a href="about.html">About us</a></li>
<li><a href="employees.html">Employees</a></li>
<li><a href="where.html">Where we are</a></li>
<li><div class="btn-group">
<a href="index.html" class="btn btn-default"><img src="img/hr.png" alt="" title = "Hrvatski" > </a>
</div></li>
</ul>
</div>
</div><!--/.nav-collapse -->
</div>
// add this in your css
li.pullDown a:before
{
position: absolute;
width: 100%;
height: 2px;
left: 0px;
top: 0px;
content: '';
background: #FFF;
opacity: 0.3;
transition: all 0.3s;
}
li.pullDown a:hover:before
{
height: 100%;
}
答案 1 :(得分:0)
好吧,我想通了,只需要添加这个选择器:
.navbar-default .navbar-nav > li > a:before {
position: absolute;
width: 100%;
height: 2px;
left: 10px;
bottom: 45px;
content: '';
background: green;
opacity: 0.3;
transition: all 0.3s;
}
.navbar-default .navbar-nav > li > a:hover:before{
height: 100%;
}
我之前尝试过这个,但是背景颜色设置为#FFF(与导航栏相同),所以我无法看到任何动画。无论如何,谢谢你的建议。