Font Awesome和Bootstrap 4 Navbar

时间:2016-01-26 02:09:47

标签: twitter-bootstrap-4 bootstrap-4

我正在寻找使用Fontawesome和Bootstrap 4的Navbar组件的示例,以便我有一个文本描述和一个彼此相邻的图标。

1 个答案:

答案 0 :(得分:8)

好吧,首先看Bootstrap 4 - Glyphicons migration?。你也可以简单地从CDN加载Font Awesoms的CSS:

导航栏中的链接只是“普通”锚点(a),因此您可以在其中添加图标:

<a class="nav-link" href="#">
Features<i class="fa fa-bell-o"></i></a>

示例:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<nav class="navbar navbar-light bg-faded">
  <a class="navbar-brand" href="#"><i class="fa fa-stack-overflow"></i>Navbar</a>
  <ul class="nav navbar-nav">
    <li class="nav-item active">
      <a class="nav-link" href="#"><i class="fa fa-home"></i>
Home <span class="sr-only">(current)</span></a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">
Features<i class="fa fa-bell-o"></i></a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#"><i class="fa fa-btc"></i>
Pricing</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#"><i class="fa fa-user-plus"></i>
About</a>
    </li>
  </ul>
  <form class="form-inline pull-xs-right">
    <input class="form-control" type="text" placeholder="Search">
    <button class="btn btn-success-outline" type="submit"><i class="fa fa-search"></i>
Search</button>
  </form>
</nav>

要在搜索表单的placeholder中添加搜索图标,请参阅:Use Font Awesome Icon in Placeholder