[英]How do you disable view encapsulation in a third party component in angular2/4?
I want to override the styles for an open source component I'm using, but the only way I can find to disable view encapsulation is on a component's decorator. 我想覆盖我正在使用的开源组件的样式,但我能找到禁用视图封装的唯一方法是在组件的装饰器上。 Of course using a third party module means I can't edit the source for it. 当然使用第三方模块意味着我无法为其编辑源代码。 How else could it be done? 怎么可能呢?
edit 编辑
I know about the /deep/ styles suggestion. 我知道/ deep / styles的建议。 What I'm wanting to do is override the table styles in a third party component with the styling from bootstrap 4. The custom component has a .table class applied to it, but with view encapsulation, it is unreachable by the boostrap 4 classes. 我想要做的是使用bootstrap 4中的样式覆盖第三方组件中的表样式。自定义组件应用了一个.table类,但是通过视图封装,boostrap 4类无法访问它。
I just want to know if theres a way to blanket disable view encapsulation altogether without having to fork the code and add the component decorator property value "encapsulation: ViewEncapsulation.None" for my own use. 我只是想知道是否有一种方法来完全禁用视图封装,而不必分叉代码并添加组件装饰器属性值“encapsulation:ViewEncapsulation.None”供我自己使用。
You can use /deep/ css selector to override css style of nested components. 您可以使用/ deep / css选择器覆盖嵌套组件的css样式。 For example, the component uses third party component that creates a drop down with ".dropdown" class. 例如,组件使用第三方组件创建带有“.dropdown”类的下拉列表。
The component html: 组件html:
<ss-multiselect-dropdown #multipleSelect
[settings]="settings"
[options]="options"
[(ngModel)]="selectedOptions"
(ngModelChange)="onSelectChange($event)"></ss-multiselect-dropdown>
and here is css of the component that override the drop down class. 这是覆盖下拉类的组件的CSS。
/deep/ .dropdown {
display: inline-block;
width: 100%;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.