如何以及在何处使用 ::ng-deep? [英] How and where to use ::ng-deep?

查看:53
本文介绍了如何以及在何处使用 ::ng-deep?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Angular 4 的新手,所以谁能解释一下在 Angular 4 中如何以及在何处使用 ::ng-deep?

其实我想从父组件覆盖子组件的一些CSS属性.另外IE11支持吗?

感谢您的帮助.

解决方案

通常 /deep/shadow-piercing" 组合器可用于强制样式向下子组件.这个选择器有一个别名 >>>现在还有一个叫做 ::ng-deep.

由于/deep/combinator已被弃用,推荐使用::ng-deep

例如:

css

.overview {::ng-深{p{&:last-child {底边距:0;}}}}

它将应用于子组件

I'm new to Angular 4, so could anyone please explain how and where to use ::ng-deep in Angular 4?

Actually I want to overwrite some of the CSS properties of the child components from the parent components. Moreover is it supported on IE11?

Thanks for the help.

解决方案

Usually /deep/ "shadow-piercing" combinator can be used to force a style down to child components. This selector had an alias >>> and now has another one called ::ng-deep.

since /deep/ combinator has been deprecated, it is recommended to use ::ng-deep

For example:

<div class="overview tab-pane" id="overview" role="tabpanel" [innerHTML]="project?.getContent( 'DETAILS')"></div>

and css

.overview {
    ::ng-deep {
        p {
            &:last-child {
                margin-bottom: 0;
            }
        }
    }
}

it will be applied to child components

这篇关于如何以及在何处使用 ::ng-deep?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆