如何使用排序图标显示Bootstrap表

Dib*_*ish 30 twitter-bootstrap twitter-bootstrap-3

我是Bootstrap的新手,我要求在表格标题附近显示一个带有排序向上和向下箭头的表格.这是我的表结构

<table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th><b>#</b>  <i class='icon-arrow-up'></i><i class='icon-arrow-down'></th> **// tried** 
            <th ><b>Name</b></th>
            <th><b>Email</b></th>
            <th><b>Team</b></th>
            <th ><b>Role</b></th>
            <th ><b>Timezone</b></th>
            <th><b>Connections</b></th>
            <th><b># Posts available</b></th>
            <th><b>Last Login</b></th>
            <th><b>Posts</b></th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
Run Code Online (Sandbox Code Playgroud)

我想显示类似于下图的排序/向下箭头. 在此输入图像描述

请帮我解决这个问题.非常感谢您的帮助.谢谢.

noz*_*man 61

您可以尝试使用FontAwesome.它包含一个排序图标(http://fontawesome.io/icon/sort/).

要这样做,你会的

  1. 需要包括fontawesome:

    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
    
    Run Code Online (Sandbox Code Playgroud)
  2. 然后只需使用fontawesome-icon而不是你th的:中的default-bootstrap-icons :

    <th><b>#</b> <i class="fa fa-fw fa-sort"></i></th>
    
    Run Code Online (Sandbox Code Playgroud)

希望有所帮助.

  • 当你想显示方向时,`fa-sort-asc`和`fa-sort-desc`也很有用 (17认同)
  • 现在 font Awesome 的升序和降序箭头是“fa-sort-up”和“fa-sort-down” (3认同)

Dud*_*udi 15

将此图标与bootstrap(glyphicon)一起使用:

<span class="glyphicon glyphicon-triangle-bottom"></span>
<span class="glyphicon glyphicon-triangle-top"></span>
Run Code Online (Sandbox Code Playgroud)

http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_glyph_triangle-bottom&stacked=h

http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_glyph_triangle-bottom&stacked=h

  • @AkshayPethani 这没有任何意义,在 bootstrap 3 中没有很棒的字体。你只有字形图标,没有必要仅仅为了排序图标而引入一个全新的图标包。 (2认同)
  • **Glyphicons 图标字体** 已从 Bootstrap 4 中删除。 (2认同)