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

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

问题描述

我是Angular 4的新手,所以谁能解释一下在Angular 4中使用::ng-deep的方式和位置?

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

实际上,我想从父组件中覆盖子组件的某些CSS属性. IE11还支持吗?

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

推荐答案

通常, /deep/ shadow-piercing 组合器可用于将样式强制降为 child components .这个选择器有一个别名>>>,现在还有一个叫做:: ng-deep的别名.

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.

由于已弃用 /deep/ combinator ,因此建议使用::ng-deep

例如:

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

css

and css

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

它将应用于子组件

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

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