加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在angular2中自定义样式不起作用?

发布时间:2020-12-17 07:25:09 所属栏目:安全 来源:网络整理
导读:我正在尝试设计 ng-content使用内联css但似乎样式不适用于ng-content,我还需要做一些其他的样式设计? ng-content class="red"/ng-content p class="red"hello/p 这里的班级红色在p上工作但不在 Working Example ::内容被忽略. 这个结束了 您可以使用:: cont
我正在尝试设计< ng-content>使用内联css但似乎样式不适用于ng-content,我还需要做一些其他的样式设计?
<ng-content class="red"></ng-content> <p class="red">hello</p>

这里的班级红色在p上工作但不在

Working Example

::内容被忽略.

这个结束了

您可以使用:: 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应该足够了>>>不应该被要求,但没有它就没有应用风格.

Plunker example

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读