是否可以在bootstrap导航标签中添加图标?

时间:2015-11-09 01:20:53

标签: html css twitter-bootstrap twitter-bootstrap-3

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Case</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h3>Tabs</h3>
  <ul class="nav nav-tabs">
    <li class="active"><a href="#">Home</a></li>
    <li><a href="#">Menu 1</a></li>
    <li><a href="#">Menu 2</a></li>
    <li><a href="#">Menu 3</a></li>
  </ul>
</div>

</body>
</html>

这是示例代码。

是否可以在bootstrap导航标签中添加图标,如下图所示。

enter image description here

我想在导航标签中添加数字图标。

3 个答案:

答案 0 :(得分:10)

<强> Working demo

您可以使用badge

执行此操作
Mapper.CreateMap<DTOObject, SubObject>()
    .ForMember(dest => dest.SubPropText, opt => opt.MapFrom(x => x.BottomText))
    .ForMember(dest => dest.SubPropFont, opt => opt.MapFrom(x => x.BottomFont));

Mapper.CreateMap<DTOObject, MainObject>()
    .ForMember(dest => dest.SubPart, opt => opt.MapFrom(x => x));

和一点CSS

<li class="active"><a href="#">Home<span class="badge">140</span></a></li>

答案 1 :(得分:2)

是的,这可以通过多种方式实现。 Bootstrap有badges,这将是一个优雅的解决方案。

<span class="badge">140</span>

答案 2 :(得分:2)

插入徽章和位置相对于容器,如下所示:

&#13;
&#13;
.count-badge {
  position: relative;
  top: -50px;
  right: -50px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>

<div class="container">
  <h3>Tabs</h3>
  <ul class="nav nav-tabs">
    <li class="active"><a href="#">Home</a>
      <span class="count-badge badge">140</span>
    </li>
    <li><a href="#">Menu 1</a>
    </li>
    <li><a href="#">Menu 2</a>
    </li>
    <li><a href="#">Menu 3</a>
    </li>
  </ul>
</div>
&#13;
&#13;
&#13;