简体   繁体   English

无法在 angular 9 项目中使用外部 css 样式表

[英]Unable to use external css stylesheet in angular 9 project

I'm new to angular and was trying to implement something with W3 CSS.我是 angular 的新手,并试图用 W3 CSS 实现一些东西。 I was trying to add this css to my project.我试图将此 css 添加到我的项目中。 Below are the steps I have followed以下是我遵循的步骤

  1. Ran npm install --save w3-css in my project directory在我的项目目录中运行 npm install --save w3-css
  2. Added node_modules/w3-css/w3.css in angular.json在 angular.json 中添加node_modules/w3-css/w3.css 8CBA22E28EB17B5F5C6AE2A266AZ
 "styles": [ "src/styles.css", "node_modules/w3-css/w3.css" ],

After that I tried adding css classes to my component html file之后,我尝试将 css 类添加到我的组件 html 文件中

<div class="w3-container w3-border w3-large">
    <div class="w3-left-align"><p>Left aligned text.</p></div>
    <div class="w3-right-align"><p>Right aligned text.</p></div>
</div>

But I couldn't see any class added.但我看不到任何 class 添加。

Note: node_modules folder and angular json are in same directory.注意:node_modules 文件夹和 angular json 在同一目录下。

import your css in style.css file.在 style.css 文件中导入您的 css。

@import "../node_modules/w3-css/w3.css";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM