Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular - including CSS file in index.html

Tags:

I'm trying to use the angular2-busy library in an angular project created with the CLI, but am having an issue importing the stylesheet:

<link rel="stylesheet" href="/node_modules/angular2-busy/build/style/busy.css">

The browser is telling me that it cannot find the file, even with the correct path. I also checked that the file exists, and it does. When I take out the rel="stylesheet" I don't get the error, but then the animations don't work.

enter image description here

Here is the package I am trying to use, if anyone is curious: https://www.npmjs.com/package/angular2-busy

like image 225
ecain Avatar asked Jul 20 '17 19:07

ecain


People also ask

How do I link CSS to index HTML?

You can link this external file (. css file) to your HTML document file using the < link > tag . You can place this < link > tag Within the < head > section, and after the < title > element of your HTML file.

How are the index HTML and style CSS files connected?

Linking your HTML and CSS filescss file is in the same folder as your index. html file. The rel attribute tells the browser that this is a stylesheet. The type attribute tells the browser that this linked file should be interpreted as CSS syntax.

How do I include a CSS file in an HTML script?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.


1 Answers

Angular CLI have it's own way to initialize your global css/js.

They are located in .angular-cli.json configuration

Locate "styles": and add your css there

Example :

"styles": [    "../node_modules/angular2-busy/build/style/busy.css",    "styles.css" ], 

Hope that helps.

like image 84
penleychan Avatar answered Sep 17 '22 15:09

penleychan