css - Bootstrap Glyphicons 未在 angular2 中显示

标签 css twitter-bootstrap web angular glyphicons

我正在尝试在我的 angular2 应用程序中使用 Bootstrap 字形图标。我已经使用命令 npm install bootstrap --save 安装了 bootstrap 我的代码片段是

 <button *ngIf="pos.name == uname" type="button" class="btn btn-default       btn-sm delete" (click)="DeleteBulletin();">
   <span class="glyphicon glyphicon-trash glyph"></span>  Delete
 </button>

我在我的 styleUrls 中包含了 bootstrap- styleUrls: ['node_modules/bootstrap/dist/css/bootstrap.min.css', 'app/home.component.css']

字形出现如图所示- enter image description here

最佳答案

Boostrap 4 does not support Glyphicons 了,你可以使用 Font Awesome相反:

npm install --save fortawesome/fontawesome-free

并将 css 文件添加到您的 .angular-cli.json

"apps": [
          {
             ....
             "styles": [
                "styles.css",
                "../node_modules/bootstrap/dist/css/bootstrap.css",
                "../node_modules/font-awesome/css/font-awesome.css"
             ],
             ...
         }
       ]

],

用 Font Awesome 类替换 CSS 类:

<i class="navbar-toggler-icon fa fa-bars"> </i>

重新编译应用:ng serve

更新: 由于 Font Font-Awesome 5 和 Angular 5 有一个官方的 angular-fontawesome 包可用:

https://github.com/FortAwesome/angular-fontawesome#installation

关于css - Bootstrap Glyphicons 未在 angular2 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37916272/

相关文章:

css - 编辑 Sagepay 框架 CSS

CSS:内联标题的行高会扰乱行间距

php - Bootstrap 表单到数据库

javascript - 链接两个网页或网络应用程序的最佳方式

jquery - 在页面加载时启动 jQuery Alert

javascript - 如何使用 javascript 在鼠标悬停时更改文本颜色?

jquery - 灰色屏幕覆盖登录表单中的打开页面(例如 Mozilla Alert)

jquery - 如何阻止导航选项卡在移动 View 中打开导航栏?

html - 内容必须在列中,但表单标签不是?

asp.net - 构建一个新的 ASP.NET 应用程序 - 寻找一个好的框架