CSS - 文本图标

时间:2017-07-24 08:00:02

标签: html css

我有这个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>

我的导航如下:

navigation

现在我想在文字上面加上图标,但不知怎的,我想的并不是那么简单。 someony是否知道如何以简单的方式做到这一点?

2 个答案:

答案 0 :(得分:2)

<xlocale.h>添加到您的跨度中,以便它们换行到新行。

例如:

display:block
.glyphicon {
  display: block;
}

Ref

答案 1 :(得分:0)

尝试以下代码。

&#13;
&#13;
.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;
&#13;
&#13;