我已经使用 Bootstrap 进行了菜单导航,并且在菜单内添加了到超链接的简单过渡...在这里查看。
正如您所看到的,当您将鼠标悬停在菜单的右侧链接上时,它们会向左移动,因为我已将 CSS 设置为:
.rightlinks a:hover{
padding-right:20px;
}
.rightlinks a, .leftlinks a{
font-size:15px;
color:#000 !important;
}
.rightlinks a{
transition:padding-right 0.45s linear;
}
但问题是我只想为文本而不是图标设置动画!查看我的 HTML 代码以更好地理解:
<nav id="nav_wrapper" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="BKoodakBold leftlinks"><a href="#"><span class="glyphicon glyphicon-user"></span></a></li>
<li class="BKoodakBold leftlinks"><a href="#"><span class="glyphicon glyphicon-search"></span></a></li>
</ul>
<ul class="nav navbar-nav navbar-center">
<a class="navbar-brand" href="#"><img src="assets/img/logo.png" width="50"></a>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="BKoodakBold rightlinks"><a href="#">درباره ما <span class="glyphicon glyphicon-info-sign"></span></a></li>
<li class="BKoodakBold rightlinks"><a href="#" >میراث گویانت <span class="glyphicon glyphicon-gift"></span></a></li>
<li class="BKoodakBold rightlinks"><a href="#">صفحه اصلی <span class="glyphicon glyphicon-globe"></span></a></li>
</ul>
</div>
</div>
</nav>
如您所见,每个链接都包含一个跨度标签,它是一个图标。并且由于我的自定义 CSS,它影响了padding-right:20px;
但我不希望 span 标签受到此转换的影响。只有菜单链接或文本应该是动画的......
所以如果你知道这个问题的答案,请告诉我!谢谢 :)