首页 > 解决方案 > Angular 10:Styles.css 未加载到 Index.html

问题描述

我在index.html文件中添加了一个 html 元素,现在我想在其上添加一些样式。我已经在styles.css文件中编写了样式代码,但它没有反映在index.html元素上。

这是代码:

索引.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Angular App</title>
    <base href="/" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link
      rel="icon"
      type="image/x-icon"
      href="https://icons.com/emoj-symbol-30763.png"
    />
  </head>
  <body>
    <app-root>
      <h2 class="loading-head">Loading .........</h2>
    </app-root>
  </body>
</html>

样式.css

.loading-head { color: red; }

角.json

  "styles": [
     "src/theme.less",
     "src/styles.css"
  ],

文件结构

/src/
  --index.html
  --styles.css
/
  --angular.json

角度版本

Angular CLI: 10.1.1
Node: 14.10.1

我无法弄清楚我做错了什么以及在哪里做错了。任何人都可以帮助我吗?

标签: javascripthtmlcssangularangular-json

解决方案


推荐阅读