I created the toolbar
component with the following decorator:
@Component({
selector: 'app-toolbar',
templateUrl: './toolbar.component.html',
styleUrls: ['./toolbar.component.scss']
})
Notice that the component is using the app-toolbar
selector.
I added the following CSS in the file toolbar.component.scss
:
app-toolbar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 2;
}
But the element did not get fixed at the top. When I inspected the element in the browser, I noticed that it has received the following attributes:
<app-toolbar _ngcontent-c0 _nghost-c1>
//...
</app-toolbar>
When checking the generated CSS, it is being applied to the element app-toolbar
but with a different attribute:
app-toolbar[_ngcontent-c1] {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 2;
}
That is, the element is rendered with the _ngcontent-c0
attribute and the CSS with the _ngcontent-c1
attribute.
What's wrong? Why is the context of the element different from the CSS context?