Angular 6 中的 Css 问题

标签 css angular sass

在我的 Angular 6 应用程序中。我创建了许多组件。对于显示数据,我使用了 ng2-smart-table

我有一些隐藏默认分页栏的特定要求。并显示自定义分页。

为此,我刚刚在组件的 SCSS 文件中设置了 css。

::ng-deep .ng2-smart-pagination-nav {
   display: none
}

但这也会影响所有其他组件。

直到我知道和 RND,在 Angular 我们使用每个组件都有他们的每个 scss 文件。所以我的问题是为什么这个 css 也会影响所有其他组件?以及如何预防这个问题?

最佳答案

The /deep/ combinator works to any depth of nested components, and it applies to both the view children and content children of the component

使用

:host Use the :host pseudo-class selector to target styles in the element that hosts the component (as opposed to targeting elements inside the component's template).

:host ::ng-deep .ng2-smart-pagination-nav {
  display: none
}

关于 Angular 6 中的 Css 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52288910/

相关文章:

javascript - 如何将ts变量绑定(bind)到html?

angularjs - 找不到模块 “@angular/core/src/metadata/directives”

javascript - 与 js 共享 sass 变量 ".sass files"

html - CSS网格重复列自动填充和minmax不会使所有列的大小相同

html - 悬停框之间没有空格?

javascript - Angular推送和拼接数组元素绑定(bind)到html

css - 如何申请:hover to multiple bem statements in sass?

css - Sass 正在重组我的选择器并且它破坏了功能

html - Flowplayer 更改所有图标颜色

html - 侧边栏直到 HTML 中的底部