0

I want to add css into component [Angular 4]. I try to add this into "resume.component.ts" by styleUrls, but I can't access url of assets !!!

Please help me add css this into component. Thanks all :D

This problem here

1
  • We can't read the error or structure. Please include relevant code and project structure. Are you using angular cli? Commented May 17, 2018 at 2:42

4 Answers 4

2

you can add your css file's relative link in .angular-cli.json (or angular.json for v6) file here:

"styles": [
  // relative link
]
Sign up to request clarification or add additional context in comments.

Comments

2

There are many ways of importing CSS file into Angular application.

  1. Angular follows the component structure (angular cli) which will provide you CSS/HTML/TS/Spec.ts file per component. So you can simply add CSS file for that particular component in @component's styleUrls property (which accept array of file names) by just adding file name , no need to add full path there.

  2. If you want to add some global CSS in your application then you can add it into the .angular-cli.json file (as you are using angular v4).

  3. Another way, if you want to import CSS files into another CSS then you can use simply import syntax like this using full path

    @import '/assets/css/yourstyle.css';
    

Comments

0

You have to put your files and use the relative path from the assets folder.

For example in the above you've put a css file in src/assets/css/general_style.css, then

<link rel="stylesheet" href="assets/css/general_style.css">

Comments

0

You type wrong path. asset => assets

@import '/asset/css/main_style.css';

please change to

@import '/assets/css/main_style.css';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.