How to do it...

Let's follow the steps to create a simple component style for our PostsComponent:

  1. First, we will add a <div> element around our router-outlet, our /src/app/app.component.html template:
<div>
<router-outlet></router-outlet>
</div>
  1. This will wrap our router-outlet so that all subcomponents will be presented within this element. Next, we will add a simple style to /src/app/app.component.scss that will add a bit of padding to the top of our element:
div {
padding-top: 20px;
}
  1. In our /src/app/posts/posts.component.scss, we will style the div elements within it in a totally different way. We will add a silver background color with a gray border to all the div elements in our posts component template:
div {
background-color: silver;
border: 1px solid gray;
}

We have used the same selectors; however, since they are component styles, they do not cascade into each other and are effectively isolated from each other.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.2.23