我有一个名为 dropdown 的控件,它使用了嵌入。注意第二行的 'dropdown-content' 类:
<div>
<div *ngIf="dropdownVisible" class="dropdown-content">
<ng-content select="dropdowncontent"></ng-content>
</div>
</div>
我构建了第二个控件,它尝试使用第一个控件:
<dropdown>
<dropdowncontent>
//some stuff here
</dropdowncontent>
</dropdown>
我正在尝试使用第二个控件中的样式注释将样式应用于第一个控件的下拉内容类。
styles: [`
.dropdown-content {
border: green solid 5px;
}
`]
但是似乎没有应用样式规则。我假设我的努力因与 shadow dom 有关的事情而受阻,但我不确定。
有没有办法让父控件将样式应用到子控件?
呈现控件后,html 的开头如下所示:
<dropdown _ngcontent-lgf-3="" _nghost-lgf-4="">
<div _ngcontent-lgf-4="">
<div _ngcontent-lgf-4="" class="dropdown-content">
<dropdowncontent _ngcontent-lgf-3="">
这表明在最终的 html 中正在生成类“dropdown-content”。
最佳答案
关于css - Angular2 包含 - 将 css 应用于子元素类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37989077/