我有这个html来显示我的导航:
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav mainMenu">
<li><a href="#"><span class="glyphicon glyphicon-dashboard"></span><span class="menuText">Menu1</span></a></li>
<li><a href="#"><span class="glyphicon glyphicon-home"></span><span class="menuText">Menu2</span></a></li>
...
</ul>
</div>
我的导航如下:
现在我想在文字上面加上图标,但不知怎的,我想的并不是那么简单。 someony是否知道如何以简单的方式做到这一点?
答案 0 :(得分:2)
答案 1 :(得分:0)
尝试以下代码。
.collapse {
display: block !important;
}
.mainMenu li {
display: inline-block !important;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav mainMenu">
<li><a href="#"><span class="glyphicon glyphicon-dashboard"></span><span class="menuText">Menu1</span></a></li>
<li><a href="#"><span class="glyphicon glyphicon-home"></span><span class="menuText">Menu2</span></a></li>
...
</ul>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#"><span class="glyphicon glyphicon-dashboard"></span><span class="menuText">Menu1</span></a></li>
<li><a href="#"><span class="glyphicon glyphicon-home"></span><span class="menuText">Menu2</span></a></li>
...
</ul>
</div>
&#13;