【发布时间】:2018-06-06 00:34:51
【问题描述】:
在这里查看ngx-bootstrap source code 时:
有一个可选的class property 定义为class?: string;。
它的使用方法是什么?
是否可以添加自定义类,例如:
this.modalService.config.class = 'myClass';
在使用servive之前例如:
this.modalRef = this.modalService.show(template, {
animated: false
});
这样,我想我们可以在显示的modal中添加自定义CSS
我尝试添加自定义类但没有成功。
那个类属性不是数组,如果适用,是不是意味着我们只能添加一个自定义类?
演示:通过添加和覆盖modal 类,模式不显示
https://stackblitz.com/edit/ngx-bootstrap-3auk5l?file=app%2Fapp.component.ts
以这种方式添加 modal 类没有帮助:
this.modalRef = this.modalService.show(template, Object.assign({},
this.config, { class: 'gray modal-lg modal' }));
https://stackblitz.com/edit/ngx-bootstrap-awmkrc?file=app%2Fapp.component.ts
【问题讨论】:
-
我将您的 CSS 从 app.component.css 移动到 styles.css 并且我看到了一些不同的东西。你试过吗?
-
那个css在哪里?上面的demo链接不能修改,可以先fork一下。
-
可能很有趣,但已经在这里看到了:plnkr.co/edit/NJRvUMZN2kHZruFgeOjQ?p=preview,在我的一个问题中,看起来一样,但是当必须在复杂的应用程序中添加它以使每个组件都具有正确的功能时,它可能会更好css。不确定这是否是我们目前唯一可以实施的方式。
-
我刚刚添加了 justify 并对齐到我正在玩的 stackblitz styles.css ......死点。看起来不错。你现在有你需要的一切吗?
标签: css angular ngx-bootstrap ngx-bootstrap-modal