css - 如何在 Angular 元素中包含字体?

标签 css angular sass

我不能在我的元素中包含字体。在 Internet 上我没有找到如何执行此操作的指南。这就是我连接它们的方式:

@import "./fonts/fontello/css/fontello.scss"


@font-face
    font-family: 'latoblack'
    src: url('/fonts/LatoBlack/lato-black.eot')
    src: url('/fonts/LatoBlack/lato-black.eot?#iefix') format('embedded-opentype'),
         url:'/fonts/LatoBlack/lato-black.woff' format('woff'),
         url('/fonts/LatoBlack/lato-black.ttf') format('truetype')
    font-weight: normal
    font-style: normal

@font-face
    font-family: 'latobold'
    src: url('/fonts/LatoBold/lato-bold.eot')
    src: url('/fonts/LatoBold/lato-bold.eot?#iefix') format('embedded-opentype'),
         url:'/fonts/LatoBold/lato-bold.woff' format('woff'),
         url('/fonts/LatoBold/lato-bold.ttf') format('truetype')
    font-weight: normal
    font-style: normal

@font-face
    font-family: 'latoitalic'
    src: url('/fonts/LatoItalic/lato-italic.eot')
    src: url('/fonts/LatoItalic/lato-italic.eot?#iefix') format('embedded-opentype'),
         url:'/fonts/LatoItalic/lato-italic.woff' format('woff'),
         url('/fonts/LatoItalic/lato-italic.ttf') format('truetype')
    font-weight: normal
    font-style: normal

@font-face
    font-family: 'latolight'
    src: url('/fonts/LatoLight/lato-light.eot')
    src: url('/fonts/LatoLight/lato-light.eot?#iefix') format('embedded-opentype'),
         url:'/fonts/LatoLight/lato-light.woff' format('woff'),
         url('/fonts/LatoLight/lato-light.ttf') format('truetype')
    font-weight: normal
    font-style: normal

@font-face
    font-family: 'latoregular'
    src: url('/fonts/LatoRegular/lato-regular.eot')
    src: url('/fonts/LatoRegular/lato-regular.eot?#iefix') format('embedded-opentype'),
         url:'/fonts/LatoRegular/lato-regular.woff' format('woff'),
         url('/fonts/fonts/LatoRegular/lato-regular.ttf') format('truetype')
    font-weight: normal
    font-style: normal

我在 cmd 中没有错误,但字体不是 workfonts 在浏览中没有改变!可以写如何在 angular 中包含字体吗? enter image description here enter image description here 屏幕截图显示了文件夹的结构。

我尝试在 Assets 中包含文件夹字体并在元素字体中包含但我有错误:

 @font-face {
  23 |     font-family: 'latoitalic';
> 24 |     src: url('../assets/fonts/LatoItalic/lato-italic.eot');
     |         ^
  25 |     src: url('/fonts/LatoItalic/lato-italic.eot?#iefix') format('embedded-opentype'), {
  26 |          url:'/fonts/LatoItalic/lato-italic.woff' format('woff'),

最佳答案

您是否将 fonts 文件夹包含在 .angular-cli.jsonasserts 中?

确保将其包含在您的 .angular-cli.json 中:

"apps": [
    {
      "assets": [
        './apps/fonts'
      ]
  }
]

关于css - 如何在 Angular 元素中包含字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49622784/

相关文章:

javascript - 如何访问包装 Angular 2 observable 的构造函数的范围?

android - 在 Ionic 2 项目上安装 phonegap-plugin-push 后出错

css - 如何制作无框原子?

css - 仅对 box-shadow Inset bottom 有问题

javascript - angularJS 中的动态 Bootstrap 进度条

html - CSS : alternative to vertical-align?

css - Google Pixel C 设备用户界面不会根据 CSS 选择器更改为横向模式

javascript - 整个站点覆盖 div?

javascript - Angular 4 vs React 性能——理论与现实

css - 有没有办法让 CSS 属性 mask-image 响应?