Bootstrap 字体图标 Glyphicons 使用

比眉伴天荒 2022-01-30 10:51 482阅读 0赞

Intro

Bootstrap捆绑了200多种字体格式的字形。
字体图标:在Web项目中使用的图标字体。

依赖

两种方式,直接在HTML中使用CDN,或依赖本地文件(略)。
CDN如下:

  1. <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  2. <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  3. <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

使用

  • 简单使用search图标
    <span class="glyphicon glyphicon-search">搜索</span>
  • 在style属性中自定义元素的样式(字体颜色color, 大小font-size, 文本阴影text-shadow)。

    <span class=”glyphicon glyphicon-search”

    1. style="color: black; text-shadow: red 1px 1px 1px; font-size: 50px;">搜索</span>
  • 在按钮中使用



页面如下:
在这里插入图片描述

  • 自定制Glyphicons图标的样式
  • FontAwesome 字体图标库 使用

Code

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  8. <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  9. <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
  10. <title>Bootstrap</title>
  11. </head>
  12. <body>
  13. <span class="glyphicon glyphicon-search">搜索</span>
  14. <span class="glyphicon glyphicon-search"
  15. style="color: black; text-shadow: red 1px 1px 1px; font-size: 50px;">搜索</span>
  16. <!-- 自定义字体颜色color, 大小font-size, 文本阴影text-shadow -->
  17. <button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;">
  18. <span class="glyphicon glyphicon-user"></span> User
  19. </button>
  20. <button type="button" class="btn btn-primary btn-lg">
  21. <span class="glyphicon glyphicon-user" style="text-shadow: black 5px 3px 3px;">User</span>
  22. </button>
  23. </body>
  24. </html>

发表评论

表情:
评论列表 (有 0 条评论,482人围观)

还没有评论,来说两句吧...

相关阅读