Posted onEdited onInangular Symbols count in article: 857Reading time ≈3 mins.
这篇探讨一下Angular中::ng-deep伪类的用法。
::ng-deep是什么?
以下是::ng-deep的官方描述:
(deprecated) /deep/, >>>, and ::ng-deep Component styles normally apply only to the HTML in the component’s own template.
Applying the ::ng-deep pseudo-class to any CSS rule completely disables view-encapsulation for that rule. Any style with ::ng-deep applied becomes a global style. In order to scope the specified style to the current component and all its descendants, be sure to include the :host selector before ::ng-deep. If the ::ng-deep combinator is used without the :host pseudo-class selector, the style can bleed into other components.
<!DOCTYPE html> <html> <head> <linkrel="stylesheet"type="text/css"href="mystyle.css"> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>