【问题标题】:How to apply css in angular 2 on some specific html page?如何在某些特定的 html 页面上应用 angular 2 中的 css?
【发布时间】:2017-01-03 17:21:36
【问题描述】:

如何在 angular 2 中应用 css。我正在使用 webstorm IDE 进行编译。还面临一些缓存问题,我不得不一次又一次地删除浏览器历史记录,也对 css 中的图像路径感到困惑,如何在 css 文件中实现图像的相对路径以及如何在 css 中添加自定义样式并将它们应用于某些特定元素.

【问题讨论】:

    标签: javascript jquery html css angular


    【解决方案1】:

    通过设置 styles 或 styleUrls 元数据

    @Component({
      selector: 'hero-app',
      template: `
        <h1>Tour of Heroes</h1>
        <hero-app-main [hero]=hero></hero-app-main>`,
      styles: ['h1 { font-weight: normal; }']
    })
    

    OR

    @Component({
      selector: 'hero-app',
      templateUrl: './home.html'
      styleUrls: ['./home..css']
    })
    

    【讨论】:

      【解决方案2】:

      您可以在 component.css 文件中编写您的 css,以便它只为该组件导入 css。

      【讨论】:

        猜你喜欢
        • 2020-01-26
        • 2019-08-01
        • 1970-01-01
        • 2019-05-27
        • 1970-01-01
        • 2020-01-30
        • 2021-08-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多