css - Angular 2: How to style host element of the component? -
i have component in angular 2 called my-comp:
<my-comp></my-comp>
how 1 style host element of component in angular 2?
in polymer, use ":host" selector. tried in angular 2. doesn't work.
:host { display: block; width: 100%; height: 100%; }
i tried using component selector:
my-comp { display: block; width: 100%; height: 100%; }
both approaches don't seem work.
thanks.
there bug, fixed in meantime. :host { }
works fine now.
also supported are
:host(selector) { ... }
selector
match attributes, classes, ... on host element:host-context(selector) { ... }
selector
match elements, classes, ...on parent componentsselector /deep/ selector
(aliasselector >>> selector
doesn't work sass) styles match across element boundaries- update: sass deprecating
/deep/
.
angular (ts , dart) added::ng-deep
replacement that's compatible sass.
- update: sass deprecating
see load external css style angular 2 component
/deep/
, >>>
not affected same selector combinators in chrome deprecated.
angular emulates (rewrites) them, , therefore doesn't depend on browsers supporting them.
this why /deep/
, >>>
don't work viewencapsulation.native
enables native shadow dom , depends on browser support.
Comments
Post a Comment