bootstrap交换图标
2016-11-21 19:52:18 wangxuznb 阅读数 935

使用Glyphicons图标库

Glyphicons 是在 Web 项目中使用的图标字体。通过Bootstrap可以非常方便的使用图标。
只需要添加以下代码:

<span class="glyphicon glyphicon-home"></span>

可以通过访问网页查找所需图标的代码http://getbootstrap.com/components/#glyphicons

使用Font Awesome图标库

首先需要自己添加Font Awesome图标库
参考(包含图标库):http://www.bootcss.com/p/font-awesome/
添加代码:

<span class="icon fa fa-home"></span>

更加方便

调整导航栏图标颜色

图标所在代码如下:

<div class="navbar-collapse collapse">
    <ul class="nav navbar-nav"> 
    <li class="active"><a href="index.html"><span class="icon fa fa-home"></span>Home</a></li>
    <li><a href="#"><span class="icon fa fa-desktop"></span>Portfolio</a></li>
    <li><a href="#"><span class="icon fa fa-group"></span>Team</a></li>
    <li><a href="#"><span class="icon fa fa-envelope"></span>Contact</a></li>
    </ul>
</div>

更改导航栏图标颜色navbar.less,首先找到导航条默认样式的选择符.navbar-default,因为图标在li > a下面,所以进行如下更改:

  .navbar-nav {
    > li > a {
      color: @navbar-default-link-color;
      .icon{
        color:@gray-light;
      }

修改图标的悬停和活动颜色,需要在伪选择符&:hover和``&:focus后面添加icon类:
代码如下:

  .navbar-nav {
    > li > a {
      color: @navbar-default-link-color;
      .icon{
        color:@gray-light;
      }

      &:hover,
      &:focus,
      &:hover .icon, //added
      &:focus .icon{ //added
        color: @navbar-default-link-hover-color;
        background-color: @navbar-default-link-hover-bg;
      }

对于活动链接active,如下修改:

    > .active > a {
      &,
      &:hover,
      &:focus,
      .icon,         //added
      &:hover .icon, //added
      &:focus .icon{ //added
        color: @navbar-default-link-active-color;
        background-color: @navbar-default-link-active-bg;
      }
    }

即可实现。

2016-10-23 17:02:40 never__ends 阅读数 862
在网页中可以看到许多小图标。bootstrap中有近200个不同的小图标。他们都是字体图标
  <span class="glyphicon glyphicon-search"></span>
        <span class="glyphicon glyphicon-asterisk"></span>
        <span class="glyphicon glyphicon-plus"></span>
        <span class="glyphicon glyphicon-cloud"></span>
除了上面写出来的,在文档当中还有许多的小图标。
使用时要注意将字体文件放在项目目录当中,并且注意路径。

要更改字体图标的样式,要通过文字属性来进行修改。

http://v3.bootcss.com/components/   文档地址,其中有其他图标的类名

2016-01-09 13:12:05 qq_22560431 阅读数 823
2014-04-30 14:00:00 weixin_30551947 阅读数 2

Bootstrap 图标由 Glyphicons 提供。详情可以去bootstrap官网进行查看。

用法:

 <i class="icon_class_name"></i> 

 实例:一个搜索表单

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Example of using icons in search form - Bootstrap version 2.0</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Example of using icons in search form - Bootstrap version 2.0 from w3cschool.cc">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
    form {
    margin-top: 50px;
    }
    </style>
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/favicon.ico">
    <link rel="apple-touch-icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-114x114.png">
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="span12">
        <form class="well form-search">
              <input type="text" class="input-medium search-query">
              <button type="submit" class="btn"><i class="icon-search"></i> Search</button>
        </form>
        </div>
        </div>
        <footer>
        <p>&copy; Company 2013</p>
      </footer>
    </div>
</body>
</html>
View Code

效果:

实例:在导航中使用图标

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Example icons in navigation with Bootstrap version 2.0 from w3cschool.cc</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Example icons in navigation with Bootstrap version 2.0 from w3cschool.cc">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/favicon.ico">
    <link rel="apple-touch-icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-114x114.png">
  </head>

  <body>
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="#">w3cschool</a>
          <div class="nav-collapse">
            <ul class="nav">
              <li class="active"><a href="#"><i class="icon-user icon-white"></i> Home</a></li>
              <li><a href="#about"><i class="icon-user icon-white"></i> User</a></li>
              <li><a href="#about"><i class="icon-download icon-white"></i> Downlaod</a></li>
              <li><a href="#about"><i class="icon-upload icon-white"></i> Upload</a></li>
              <li><a href="#about"><i class="icon-play-circle  icon-white"></i> Play Circle</a></li>
              <li><a href="#about"><i class="icon-bookmark  icon-white"></i> Bookmark</a></li>
              <li><a href="#about"><i class="icon-gift icon-white"></i> Gift</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

 <hr>
    </div> <!-- /container -->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-transition.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-modal.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-scrollspy.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tab.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tooltip.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-popover.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-button.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-collapse.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-carousel.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-typeahead.js"></script>

  </body>
</html>
View Code

效果如下:

实例:在按钮和按钮组中使用图标

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Example of using icons in buttons and button groups - Bootstrap version 2.0</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Example of using icons in buttons and button groups - Bootstrap version 2.0 from w3cschool.cc">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
    form {
    margin-top: 50px;
    }
    </style>
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/favicon.ico">
    <link rel="apple-touch-icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-114x114.png">
  </head>
  <body>
    <div class="container">
      <div class="row">
    <div class="span4">
      <div class="btn-toolbar" style="margin-bottom: 9px">
        <div class="btn-group">
          <a class="btn" href="#"><i class="icon-align-left"></i></a>
          <a class="btn" href="#"><i class="icon-align-center"></i></a>
          <a class="btn" href="#"><i class="icon-align-right"></i></a>
          <a class="btn" href="#"><i class="icon-align-justify"></i></a>
        </div>
        <div class="btn-group">
          <a class="btn btn-primary" href="#"><i class="icon-user icon-white"></i> User</a>
          <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#"><i class="icon-pencil"></i> Edit</a></li>
            <li><a href="#"><i class="icon-trash"></i> Delete</a></li>
            <li><a href="#"><i class="icon-ban-circle"></i> Ban</a></li>
            <li class="divider"></li>
            <li><a href="#"><i class="i"></i> Make admin</a></li>
          </ul>
        </div>
      </div>
      <p>
        <a class="btn" href="#"><i class="icon-refresh"></i> Refresh</a>
        <a class="btn btn-success" href="#"><i class="icon-shopping-cart icon-white"></i> Checkout</a>
        <a class="btn btn-danger" href="#"><i class="icon-trash icon-white"></i> Delete</a>
      </p>
      <p>
        <a class="btn btn-large" href="#"><i class="icon-comment"></i> Comment</a>
        <a class="btn btn-small" href="#"><i class="icon-cog"></i> Settings</a>
        <a class="btn btn-small btn-info" href="#"><i class="icon-info-sign icon-white"></i> More Info</a>
      </p>
    </div>
       </div>
    </div>
     <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-transition.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-modal.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-scrollspy.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tab.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tooltip.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-popover.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-button.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-collapse.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-carousel.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
View Code

效果如下:

转载于:https://www.cnblogs.com/LT0314/p/3701219.html

2012-11-02 11:30:00 weixin_34239592 阅读数 10

Bootstrap icons

http://fortawesome.github.com/Font-Awesome/#all-icons

转载于:https://my.oschina.net/emrys/blog/86669

Bootstrap图标

阅读数 2

Bootstrap 图标

阅读数 1762

bootstrap图标

阅读数 6

bootstrap的图标

阅读数 550

博文 来自: sevenliuxin

Bootstrap 图标

阅读数 988

没有更多推荐了,返回首页