CSS 问题 Ngx 表 angular2 泳道

标签 css angular datatable ngx-datatable

我目前在让 ngx-datatable 具有正确的 css 方面遇到问题。我在我的 css 文件中有这个来导入正确的 css。

@import '@swimlane/ngx-datatable/release/index.css';
@import '@swimlane/ngx-datatable/release/themes/material.css';
@import '@swimlane/ngx-datatable/release/assets/icons.css';

它似乎只做了它应该做的一半。这是我调用库的 html 部分。

  <ngx-datatable  class="material striped"
    class="material"
    [rows]="rows"
    [columns]="columns"
    [columnMode]="'force'"
    [headerHeight]="50"
    [footerHeight]="50"
    [rowHeight]="100">
  </ngx-datatable>

如果有人知道为什么会发生这种情况,那将非常有帮助。

@amcdnl任何线索,如果您阅读本文,很抱歉打扰您

CSS Issue

最佳答案

我认为它与 View 封装有关。基本上你的 css 将被限定在像 [_ngcontent-c5] 这样的属性范围内,因为你的模板中的元素会自动拥有它。

然而,通过数据表添加到 dom 的元素可能没有该属性,导致样式无所事事。

您可以通过向您的组件添加选项 encapsulation: ViewEncapsulation.None 来解决这个问题,如下所示:

import { ViewEncapsulation } from '@angular/core';
@Component({
  [...] // other code like template and style urls
  encapsulation: ViewEncapsulation.None
})

关于CSS 问题 Ngx 表 angular2 泳道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44166811/

相关文章:

html - 下拉菜单中的导航栏搜索框会使其他导航栏图标崩溃

html - 如何根据帧大小定位div位置?

javascript - jQuery DataTables 日期范围样式

javascript - HTML 到 JS 数据表 : Still show a removed row after sorting or page size change?

javascript - 为什么我的 Ajax 会调用两次 fire ?

html - 如何实现具有 3 列和页脚的布局

html - 如何将 Html 与可用区域的边缘对齐/锚定?

Angular 服务 : best pratice for observables

javascript - CORS OPTIONS 请求成功,但在 Safari 中挂起

angular - 我如何使用 typeahead 来获取/呈现对象,但接收并响应字符串?