如何在像facebook jewel-icons这样的固定顶部栏图标中添加boostrap

时间:2015-07-04 18:47:56

标签: html css twitter-bootstrap

我使用bootstrap和固定顶部导航栏,如何在Facebook导航栏中添加图标(图标:朋友,消息,通知)到导航栏?我在PNG文件中有图标。

2 个答案:

答案 0 :(得分:1)

引导程序中内置了名为Glyphicons的图标。您可以使用这些图标。

您也可以根据需要使用自己的图标,只需将图像放在导航列表中即可。

这是一个例子:



.my-icon {
    width: 20px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default">
  <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>
      <a class="navbar-brand" href="#">Facebook</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">      
      <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
      </form>     
      <ul class="nav navbar-nav">
          <li class="active"><a href="#"><img class="my-icon" src="http://images.onlinelabels.com/images/clip-art/acspike/acspike_male_user_icon.png" /> Friends<span class="sr-only">(current)</span></a></li>
          <li><a href="#"><span class="glyphicon glyphicon-envelope"></span> Messages</a></li>     
        <li><a href="#"><span class="badge">4</span> Notifications</a></li> 
      </ul>    
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

如果你写了div,你想把它粘在顶部或底部使用这个类:

navbar-fixed-top //this class sticks the div to the top

Jsfiddle