我正在寻找使用Fontawesome和Bootstrap 4的Navbar组件的示例,以便我有一个文本描述和一个彼此相邻的图标。
答案 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