我正在尝试设计< ng-content>使用内联css但似乎样式不适用于ng-content,我还需要做一些其他的样式设计?
<ng-content class="red"></ng-content> <p class="red">hello</p>
这里的班级红色在p上工作但不在
::内容被忽略.
原文链接:https://www.f2er.com/angularjs/141921.html这个结束了
您可以使用:: content选择器
styles: ['.red {color:red} :host >>> upper {color:green}']
要么
styles: ['.red {color:red} :host >>> * {color:green}']
And if there are fellow LESS users,seems that LESS compiler dislikes
>>>
Syntax,so you need to add an alias for that,eg.@deep: ~">>>";
and then use that like@{deep} { /* your deep styles here */ }
另见讨论https://github.com/angular/angular/issues/7400#issuecomment-246922468
您可以使用:: content选择器
styles: ['.red {color:red} ::content >>> upper {color:green}']
要么
styles: ['.red {color:red} ::content >>> * {color:green}']
根据网络组件spec :: content应该足够了>>>不应该被要求,但没有它就没有应用风格.