0

How to apply css in angular 2. I am using webstorm IDE for compilation. Also facing some cache issue, again and again I have to delete browser history, also confused about images path in css, how do i implement relative paths of images in css files and how to add custom styles in css and apply them on some specific element.

2 Answers 2

2

By setting styles or styleUrls metadata

@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']
})
Sign up to request clarification or add additional context in comments.

Comments

1

You can write your css in the component.css file so that it imports the css only for that component.

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.